MCPcopy Create free account
hub / github.com/UESTCByteDance/ByteRhythm / UploadVideo

Function UploadVideo

util/upload.go:14–37  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

12)
13
14func UploadVideo(data []byte) (VideoUrl string, err error) {
15 config.Init()
16 size := int64(len(data))
17 key := fmt.Sprintf("%s.mp4", GenerateUUID())
18 putPolicy := storage.PutPolicy{
19 Scope: fmt.Sprintf("%s:%s", config.Bucket, key),
20 }
21 mac := qbox.NewMac(config.AccessKey, config.SecretKey)
22 upToken := putPolicy.UploadToken(mac)
23 cfg := storage.Config{}
24 uploader := storage.NewFormUploader(&cfg)
25 ret := storage.PutRet{}
26 putExtra := storage.PutExtra{
27 Params: map[string]string{
28 "x:name": "github logo",
29 },
30 }
31 err = uploader.Put(context.Background(), &ret, upToken, key, bytes.NewReader(data), size, &putExtra)
32 if err != nil {
33 return "", err
34 }
35
36 return fmt.Sprintf("%s/%s", config.Domain, ret.Key), nil
37}
38
39func UploadJPG(imgPath string, videoUrl string) string {
40 config.Init()

Callers 1

VideoMQ2DBFunction · 0.92

Calls 2

InitFunction · 0.92
GenerateUUIDFunction · 0.85

Tested by

no test coverage detected