feat(canvas): 媒体地址 - 图片和视频右键支持复制私有 OSS 签名地址
This commit is contained in:
1 parent
b832668813
commit
fca7c95b64
6 files changed
+60
-2
No files matched your search
@@ -128,6 +128,27 @@ func RegisterUserDataRoutes(r *gin.RouterGroup, svc *service.Service) {
|
||||
}
|
||||
ok(c, gin.H{"resource": resource})
|
||||
})
|
||||
r.GET("/resources/:id/oss-url", func(c *gin.Context) {
|
||||
user, err := currentUser(c, svc)
|
||||
if err != nil {
|
||||
failService(c, err)
|
||||
return
|
||||
}
|
||||
resource, err := svc.Resource(user.ID, c.Param("id"))
|
||||
if err != nil {
|
||||
fail(c, http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
ossURL, err := svc.DirectResourceURL(user.ID, resource.ID)
|
||||
if err != nil {
|
||||
failService(c, err)
|
||||
return
|
||||
}
|
||||
// 签名地址只用于当前复制动作,禁止浏览器或中间代理缓存。
|
||||
c.Header("Cache-Control", "private, no-store")
|
||||
c.Header("Referrer-Policy", "no-referrer")
|
||||
ok(c, gin.H{"url": ossURL})
|
||||
})
|
||||
r.GET("/resources/:id/file", func(c *gin.Context) {
|
||||
user, err := currentUser(c, svc)
|
||||
if err != nil {
|
||||
|
||||
@@ -69,7 +69,7 @@ func (s *Service) DirectResourceURL(userID string, id string) (string, error) {
|
||||
return "", BadAuthRequest("资源尚未上传完成")
|
||||
}
|
||||
if resource.Provider == "local" {
|
||||
return "", nil
|
||||
return "", BadAuthRequest("当前资源未存储在 OSS")
|
||||
}
|
||||
setting, err := s.ossSettingForResource(userID, resource)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user