Skip to content

Commit

Permalink
feat(aliyundrive): add doc and video preview api
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 11, 2022
1 parent cd73e34 commit 5ff0d85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion drivers/aliyundrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,29 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
}

func (d *AliDrive) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) {
return nil, errs.NotSupport
var resp base.Json
var url string
data := base.Json{
"drive_id": d.DriveId,
"file_id": args.Obj.GetID(),
}
switch args.Method {
case "doc_preview":
url = "https://api.aliyundrive.com/v2/file/get_office_preview_url"
data["access_token"] = d.AccessToken
case "video_preview":
url = "https://api.aliyundrive.com/v2/file/get_video_preview_play_info"
data["category"] = "live_transcoding"
default:
return nil, errs.NotSupport
}
_, err, _ := d.request(url, http.MethodPost, func(req *resty.Request) {
req.SetBody(data)
}, &resp)
if err != nil {
return nil, err
}
return resp, nil
}

var _ driver.Driver = (*AliDrive)(nil)
1 change: 1 addition & 0 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func admin(g *gin.RouterGroup) {
func _fs(g *gin.RouterGroup) {
g.Any("/list", handles.FsList)
g.Any("/get", handles.FsGet)
g.Any("/other", handles.FsOther)
g.Any("/dirs", handles.FsDirs)
g.POST("/mkdir", handles.FsMkdir)
g.POST("/rename", handles.FsRename)
Expand Down

0 comments on commit 5ff0d85

Please sign in to comment.