9
9
10
10
"a2os/safeu-backend/common"
11
11
12
+ "github.com/aliyun/aliyun-oss-go-sdk/oss"
12
13
"github.com/gin-gonic/gin"
13
14
"github.com/gin-gonic/gin/json"
14
15
"github.com/satori/go.uuid"
@@ -119,7 +120,7 @@ func DownloadItems(c *gin.Context) {
119
120
120
121
// 删除数据库记录
121
122
db .Delete (& singleItem )
122
-
123
+ common . DeleteRedisRecodeFromRecode ( singleItem . ReCode )
123
124
// 返回 410 Gone
124
125
c .JSON (http .StatusGone , gin.H {
125
126
"error" : "Over the expired time." ,
@@ -139,7 +140,7 @@ func DownloadItems(c *gin.Context) {
139
140
140
141
// 删除数据库记录
141
142
db .Delete (& singleItem )
142
-
143
+ common . DeleteRedisRecodeFromRecode ( singleItem . ReCode )
143
144
c .JSON (http .StatusGone , gin.H {
144
145
"error" : "Out of downloadable count." ,
145
146
})
@@ -306,3 +307,19 @@ func GetZipEndpoint() (string, error) {
306
307
307
308
return zipEndpoint , nil
308
309
}
310
+
311
+ // 获取签名URL
312
+ func GetSignURL (itemBucket string , itemPath string , client * oss.Client ) (string , error ) {
313
+
314
+ bucket , err := client .Bucket (itemBucket )
315
+ if err != nil {
316
+ log .Println (fmt .Sprintf ("Func: GetSignURL Get Client %v Bucket %s Failed %s" , client , itemBucket , err .Error ()))
317
+ return "" , err
318
+ }
319
+ signedURL , err := bucket .SignURL (itemPath , oss .HTTPGet , common .FILE_DOWNLOAD_SIGNURL_TIME )
320
+ if err != nil {
321
+ log .Println (fmt .Sprintf ("Func: GetSignURL Get Bucket %s Object %s Failed %s" , itemBucket , itemPath , err .Error ()))
322
+ return "" , err
323
+ }
324
+ return signedURL , nil
325
+ }
0 commit comments