Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7cbf5d

Browse files
fix: support windows specific zip mime type for template uploads (#15442)
![image](https://github.com/user-attachments/assets/15ae6dc4-84a3-4c20-b603-ed38cc14a250)Despite being encoded the same, the API was previously rejecting zipfiles with this MIME type.
1 parent718722a commitf7cbf5d

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

‎coderd/files.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ import (
2525
)
2626

2727
const (
28-
tarMimeType="application/x-tar"
29-
zipMimeType="application/zip"
28+
tarMimeType="application/x-tar"
29+
zipMimeType="application/zip"
30+
windowsZipMimeType="application/x-zip-compressed"
3031

3132
HTTPFileMaxBytes=10* (10<<20)
3233
)
@@ -48,7 +49,7 @@ func (api *API) postFile(rw http.ResponseWriter, r *http.Request) {
4849

4950
contentType:=r.Header.Get("Content-Type")
5051
switchcontentType {
51-
casetarMimeType,zipMimeType:
52+
casetarMimeType,zipMimeType,windowsZipMimeType:
5253
default:
5354
httpapi.Write(ctx,rw,http.StatusBadRequest, codersdk.Response{
5455
Message:fmt.Sprintf("Unsupported content type header %q.",contentType),
@@ -66,7 +67,7 @@ func (api *API) postFile(rw http.ResponseWriter, r *http.Request) {
6667
return
6768
}
6869

69-
ifcontentType==zipMimeType {
70+
ifcontentType==zipMimeType||contentType==windowsZipMimeType{
7071
zipReader,err:=zip.NewReader(bytes.NewReader(data),int64(len(data)))
7172
iferr!=nil {
7273
httpapi.Write(ctx,rw,http.StatusBadRequest, codersdk.Response{

‎coderd/files_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ func TestPostFiles(t *testing.T) {
4343
require.NoError(t,err)
4444
})
4545

46+
t.Run("InsertWindowsZip",func(t*testing.T) {
47+
t.Parallel()
48+
client:=coderdtest.New(t,nil)
49+
_=coderdtest.CreateFirstUser(t,client)
50+
51+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
52+
defercancel()
53+
54+
_,err:=client.Upload(ctx,"application/x-zip-compressed",bytes.NewReader(archivetest.TestZipFileBytes()))
55+
require.NoError(t,err)
56+
})
57+
4658
t.Run("InsertAlreadyExists",func(t*testing.T) {
4759
t.Parallel()
4860
client:=coderdtest.New(t,nil)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp