Preserve uploaded file extensions

This commit is contained in:
richjohnrambo
2026-09-07 16:13:20 +08:00
parent 35da3025a3
commit 8a9e202b56
8 changed files with 139 additions and 14 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ func (h *testLargeFileMediaHandler) Upload(def *types.FileDef, file io.Reader) (
data, _ := io.ReadAll(file)
h.def = def
h.data = string(data)
def.Location = "/v0/file/s/" + def.Uid().String() + ".txt"
def.Location = "/v0/file/s/" + media.FileURLName(def)
def.ETag = "etag"
return def.Location, int64(len(data)), nil
}
@@ -252,7 +252,7 @@ func TestLargeFileReceiveMeetingNoteUploadCreatesNoteFile(t *testing.T) {
params["meeting_id"] != "mtg_test" || params["note_file_id"] != "mnote_note-1" {
t.Fatalf("unexpected upload params: %#v", params)
}
if handler.data != "hello notes" || notes.createdFileID != fileID.String() || notes.createdMeetingID != "mtg_test" || notes.createdIdempotencyKey != "upload-meeting-note-1" {
if handler.data != "hello notes" || handler.def.OriginalName != "notes.txt" || notes.createdFileID != fileID.String() || notes.createdMeetingID != "mtg_test" || notes.createdIdempotencyKey != "upload-meeting-note-1" {
t.Fatalf("unexpected side effects: handler=%#v notes=%#v", handler, notes)
}
}