mirror of https://github.com/Superioz/aqua.git
Fix no file in form panic
This commit is contained in:
parent
bbba0db935
commit
800e3dfaaf
|
@ -47,6 +47,12 @@ var (
|
|||
emptyRequestMetadata = &RequestMetadata{Expiration: storage.ExpireNever}
|
||||
)
|
||||
|
||||
type RequestFormFile struct {
|
||||
File multipart.File
|
||||
ContentType string
|
||||
ContentLength int64
|
||||
}
|
||||
|
||||
type RequestMetadata struct {
|
||||
Expiration int64 `json:"expiration"`
|
||||
}
|
||||
|
@ -100,6 +106,10 @@ func (h *UploadHandler) Upload(c *gin.Context) {
|
|||
c.JSON(http.StatusBadRequest, gin.H{"msg": "too many files in form"})
|
||||
return
|
||||
}
|
||||
if len(files) == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"msg": "no file in form"})
|
||||
return
|
||||
}
|
||||
file := files[0]
|
||||
|
||||
if c.Request.Header.Get("Content-Length") == "" {
|
||||
|
|
Loading…
Reference in New Issue