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

This commit is contained in:
Ariel Leyva
2026-02-14 01:37:28 -05:00
committed by GitHub
parent 88b97def9e
commit f67bccf8c5
11 changed files with 276 additions and 321 deletions

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 != "" {