github.com/qiniu/go-sdk/v7@v7.27.0/examples/video_pfop/main.go (about) 1 package main 2 3 import ( 4 "encoding/base64" 5 "fmt" 6 "os" 7 "strings" 8 9 "github.com/qiniu/go-sdk/v7/auth" 10 "github.com/qiniu/go-sdk/v7/storage" 11 ) 12 13 var ( 14 accessKey = os.Getenv("QINIU_ACCESS_KEY") 15 secretKey = os.Getenv("QINIU_SECRET_KEY") 16 bucket = os.Getenv("QINIU_TEST_BUCKET") 17 // 数据处理的私有队列,必须指定以保障处理速度 18 pipeline = os.Getenv("QINIU_TEST_PIPELINE") 19 ) 20 21 func main() { 22 mac := auth.New(accessKey, secretKey) 23 cfg := storage.Config{ 24 UseHTTPS: true, 25 } 26 // 指定空间所在的区域,如果不指定将自动探测 27 // 如果没有特殊需求,默认不需要指定 28 // cfg.Zone=&storage.ZoneHuabei 29 operationManager := storage.NewOperationManager(mac, &cfg) 30 key := "qiniu.mp4" 31 saveBucket := bucket 32 // 处理指令集合 33 fopAvthumb := fmt.Sprintf("avthumb/mp4/s/480x320/vb/500k|saveas/%s", 34 storage.EncodedEntry(saveBucket, "pfop_test_qiniu.mp4")) 35 fopVframe := fmt.Sprintf("vframe/jpg/offset/10|saveas/%s", 36 storage.EncodedEntry(saveBucket, "pfop_test_qiniu.jpg")) 37 fopVsample := fmt.Sprintf("vsample/jpg/interval/20/pattern/%s", 38 base64.URLEncoding.EncodeToString([]byte("pfop_test_$(count).jpg"))) 39 fopBatch := []string{fopAvthumb, fopVframe, fopVsample} 40 fops := strings.Join(fopBatch, ";") 41 // 强制重新执行数据处理任务 42 force := true 43 // 数据处理指令全部完成之后,通知该地址 44 notifyURL := "http://api.example.com/pfop/callback" 45 // 数据处理的私有队列,必须指定以保障处理速度 46 persistentId, err := operationManager.Pfop(bucket, key, fops, pipeline, notifyURL, force) 47 if err != nil { 48 fmt.Println(err) 49 return 50 } 51 fmt.Println(persistentId) 52 }