This commit is contained in:
@@ -94,7 +94,7 @@ func UploadFile(d UploadDeps) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
pub := publicObjectURL(d.S3PublicBase, d.S3Bucket, d.AWSRegion, key)
|
||||
writeUploadJSON(w, pub, hdr.Filename, name, ct, int64(len(data)), data, "s3")
|
||||
writeUploadJSON(w, r, pub, hdr.Filename, name, ct, int64(len(data)), data, "s3")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -113,15 +113,18 @@ func UploadFile(d UploadDeps) http.HandlerFunc {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
writeUploadJSON(w, "/uploads/"+name, hdr.Filename, name, ct, int64(len(data)), data, "local")
|
||||
writeUploadJSON(w, r, "/uploads/"+name, hdr.Filename, name, ct, int64(len(data)), data, "local")
|
||||
}
|
||||
}
|
||||
|
||||
func writeUploadJSON(w http.ResponseWriter, url, originalName, storedName, mime string, size int64, data []byte, storage string) {
|
||||
func writeUploadJSON(w http.ResponseWriter, r *http.Request, url, originalName, storedName, mime string, size int64, data []byte, storage string) {
|
||||
kind := classifyAttachmentKind(mime, originalName)
|
||||
if kind == "" {
|
||||
kind = classifyAttachmentKind(mime, storedName)
|
||||
}
|
||||
if k := strings.TrimSpace(r.FormValue("kind")); k == "image" || k == "document" || k == "video" {
|
||||
kind = k
|
||||
}
|
||||
out := map[string]any{
|
||||
"url": url,
|
||||
"filename": storedName,
|
||||
|
||||
Reference in New Issue
Block a user