Skip to content

Commit ae70fc0

Browse files
committed
BUG/MINOR: general_storage: fix error message when no FileUpload specified
1 parent f5fa575 commit ae70fc0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

handlers/general_storage.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ type StorageCreateStorageGeneralFileHandlerImpl struct {
3939
}
4040

4141
func (h *StorageCreateStorageGeneralFileHandlerImpl) Handle(params storage.CreateStorageGeneralFileParams, principal interface{}) middleware.Responder {
42+
if params.FileUpload == nil {
43+
e := &models.Error{
44+
Code: misc.Int64P(400),
45+
Message: misc.StringP("No file_upload form param specified"),
46+
}
47+
return storage.NewReplaceStorageGeneralFileBadRequest().WithPayload(e)
48+
}
49+
4250
file, ok := params.FileUpload.(*runtime.File)
4351
if !ok {
4452
return storage.NewCreateStorageGeneralFileBadRequest()
@@ -189,6 +197,14 @@ func (h *StorageReplaceStorageGeneralFileHandlerImpl) Handle(params storage.Repl
189197
return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e)
190198
}
191199

200+
if params.FileUpload == nil {
201+
e := &models.Error{
202+
Code: misc.Int64P(400),
203+
Message: misc.StringP("No file_upload form param specified"),
204+
}
205+
return storage.NewReplaceStorageGeneralFileBadRequest().WithPayload(e)
206+
}
207+
192208
data, err := io.ReadAll(params.FileUpload)
193209
if err != nil {
194210
return storage.NewReplaceStorageGeneralFileBadRequest()

0 commit comments

Comments
 (0)