feat(files): add uploadings api (#30)

* fix(uploader, files/handlers): fix incorrect unlock, catch and check after calling api

* fix(uploader): fix uploader test

* feat(files): add uploadings api

* fix(files): register uploading handlers to api

Co-authored-by: Jia He <jiah@nvidia.com>
This commit is contained in:
Hexxa 2021-01-11 22:57:02 +08:00 committed by GitHub
parent a909df384d
commit 67c07cc81f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 398 additions and 83 deletions

View file

@ -53,11 +53,14 @@ func (h *SimpleUserHandlers) Auth() gin.HandlerFunc {
ExpireParam: "",
}
_, err = h.deps.Token().FromToken(token, claims)
claims, err = h.deps.Token().FromToken(token, claims)
if err != nil {
c.AbortWithStatusJSON(q.ErrResp(c, 401, err))
return
}
for key, val := range claims {
c.Set(key, val)
}
now := time.Now().Unix()
expire, err := strconv.ParseInt(claims[ExpireParam], 10, 64)
@ -71,6 +74,9 @@ func (h *SimpleUserHandlers) Auth() gin.HandlerFunc {
c.AbortWithStatusJSON(q.ErrResp(c, 401, errors.New("not allowed")))
return
}
} else {
// this is for UploadMgr to get user info to get related namespace
c.Set(UserParam, "quickshare_anonymous")
}
c.Next()