Skip to content

Commit 8d0f589

Browse files
committed
check
1 parent 058a662 commit 8d0f589

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

api/r0/upload_async.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ package r0
22

33
import (
44
"errors"
5-
"io"
65
"net/http"
76
"path/filepath"
87

98
"github.com/getsentry/sentry-go"
10-
"github.com/h2non/filetype"
119
"github.com/sirupsen/logrus"
1210
"github.com/t2bot/matrix-media-repo/api/_apimeta"
1311
"github.com/t2bot/matrix-media-repo/api/_responses"
@@ -59,15 +57,15 @@ func UploadMediaAsync(r *http.Request, rctx rcontext.RequestContext, user _apime
5957
}
6058

6159
// GK-CUSTOMIZATION: Check if the file type is supported
62-
buf, _ := io.ReadAll(r.Body)
63-
kind, _ := filetype.Match(buf)
64-
if !isSupportedFileType(kind.Extension) {
65-
return &_responses.ErrorResponse{
66-
Code: common.ErrCodeBadRequest,
67-
Message: "Unsupported file type.",
68-
InternalCode: common.ErrCodeBadRequest,
69-
}
70-
}
60+
// buf, _ := io.ReadAll(r.Body)
61+
// kind, _ := filetype.Match(buf)
62+
// if !isSupportedFileType(kind.Extension) {
63+
// return &_responses.ErrorResponse{
64+
// Code: common.ErrCodeBadRequest,
65+
// Message: "Unsupported file type.",
66+
// InternalCode: common.ErrCodeBadRequest,
67+
// }
68+
// }
7169

7270
rctx = rctx.LogWithFields(logrus.Fields{
7371
"mediaId": mediaId,

api/r0/upload_sync.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package r0
22

33
import (
44
"errors"
5-
"io"
65
"net/http"
76
"path/filepath"
87
"strconv"
98

109
"github.com/getsentry/sentry-go"
11-
"github.com/h2non/filetype"
1210
"github.com/sirupsen/logrus"
1311
"github.com/t2bot/matrix-media-repo/api/_apimeta"
1412
"github.com/t2bot/matrix-media-repo/api/_responses"
@@ -35,15 +33,15 @@ func UploadMediaSync(r *http.Request, rctx rcontext.RequestContext, user _apimet
3533
}
3634

3735
// GK-CUSTOMIZATION: Check if the file type is supported
38-
buf, _ := io.ReadAll(r.Body)
39-
kind, _ := filetype.Match(buf)
40-
if !isSupportedFileType(kind.Extension) {
41-
return &_responses.ErrorResponse{
42-
Code: common.ErrCodeBadRequest,
43-
Message: "Unsupported file type.",
44-
InternalCode: common.ErrCodeBadRequest,
45-
}
46-
}
36+
// buf, _ := io.ReadAll(r.Body)
37+
// kind, _ := filetype.Match(buf)
38+
// if !isSupportedFileType(kind.Extension) {
39+
// return &_responses.ErrorResponse{
40+
// Code: common.ErrCodeBadRequest,
41+
// Message: "Unsupported file type.",
42+
// InternalCode: common.ErrCodeBadRequest,
43+
// }
44+
// }
4745

4846
rctx = rctx.LogWithFields(logrus.Fields{
4947
"filename": filename,

0 commit comments

Comments
 (0)