feat: support for multiple encodings in CSV files (#5756)

This commit is contained in:
Ariel Leyva authored and GitHub committed 2026-02-14 07:37:28 +01:00
1 parent 88b97def9e
commit f67bccf8c5
11 files changed
+276 -321

No files matched your search

+21
View File
@@ -36,10 +36,31 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
return errToStatus(err), err
}
encoding := r.Header.Get("X-Encoding")
if file.IsDir {
file.Sorting = d.user.Sorting
file.ApplySort()
return renderJSON(w, r, file)
} else if encoding == "true" {
if file.Type != "text" {
return http.StatusUnsupportedMediaType, fmt.Errorf("file is not a text file")
}
f, err := d.user.Fs.Open(r.URL.Path)
if err != nil {
return errToStatus(err), err
}
defer f.Close()
data, err := io.ReadAll(f)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("Content-Type", "application/octet-stream")
w.WriteHeader(http.StatusOK)
_, err = w.Write(data)
return 0, err
}
if checksum := r.URL.Query().Get("checksum"); checksum != "" {