Skip to content

Commit

Permalink
签名视频
Browse files Browse the repository at this point in the history
  • Loading branch information
bydmm committed Sep 4, 2019
1 parent 0d3a258 commit 22062e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.idea
docker-compose.yml
fabfile.py
go.sum
go.sum
debug
8 changes: 8 additions & 0 deletions model/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ func (video *Video) AvatarURL() string {
return signedGetURL
}

// VideoURL 视频地址
func (video *Video) VideoURL() string {
client, _ := oss.New(os.Getenv("OSS_END_POINT"), os.Getenv("OSS_ACCESS_KEY_ID"), os.Getenv("OSS_ACCESS_KEY_SECRET"))
bucket, _ := client.Bucket(os.Getenv("OSS_BUCKET"))
signedGetURL, _ := bucket.SignURL(video.URL, oss.HTTPGet, 600)
return signedGetURL
}

// View 点击数
func (video *Video) View() uint64 {
countStr, _ := cache.RedisClient.Get(cache.VideoViewKey(video.ID)).Result()
Expand Down
2 changes: 1 addition & 1 deletion serializer/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func BuildVideo(item model.Video) Video {
ID: item.ID,
Title: item.Title,
Info: item.Info,
URL: item.URL,
URL: item.VideoURL(),
Avatar: item.AvatarURL(),
View: item.View(),
CreatedAt: item.CreatedAt.Unix(),
Expand Down

0 comments on commit 22062e4

Please sign in to comment.