Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c961987

Browse files
committed
fix: support windows specific zip mime type for template uploads
1 parent f769456 commit c961987

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

coderd/files.go

+5-4
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
switch contentType {
51-
case tarMimeType, zipMimeType:
52+
case tarMimeType, 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-
if contentType == zipMimeType {
70+
if contentType == zipMimeType || contentType == windowsZipMimeType {
7071
zipReader, err := zip.NewReader(bytes.NewReader(data), int64(len(data)))
7172
if err != nil {
7273
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{

0 commit comments

Comments
 (0)