File tree 1 file changed +11
-7
lines changed
routers/api/packages/swift
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -306,16 +306,20 @@ func UploadPackageFile(ctx *context.Context) {
306
306
307
307
var file io.ReadCloser
308
308
multipartFile , _ , err := ctx .Req .FormFile ("source-archive" )
309
- if err != nil {
309
+ if err != nil && ! errors .Is (err , http .ErrMissingFile ) {
310
+ apiError (ctx , http .StatusBadRequest , err )
311
+ return
312
+ }
313
+
314
+ if multipartFile != nil {
315
+ file = multipartFile
316
+ } else {
310
317
content := ctx .Req .FormValue ("source-archive" )
311
- if content != "" {
312
- file = io .NopCloser (strings .NewReader (content ))
313
- } else {
314
- apiError (ctx , http .StatusBadRequest , err )
318
+ if content == "" {
319
+ apiError (ctx , http .StatusBadRequest , "source-archive is required either as file or form value" )
315
320
return
316
321
}
317
- } else {
318
- file = multipartFile
322
+ file = io .NopCloser (strings .NewReader (content ))
319
323
}
320
324
defer file .Close ()
321
325
You can’t perform that action at this time.
0 commit comments