예제 #1
0
파일: gout.go 프로젝트: gnolizuh/gout
func ks3_flv_upload(c *s3.S3, idx_cfg IndexConfigT, ak string, sk string, key string, file string) bool {

	if len(idx_cfg.vdoid) == 0 {
		return true
	}

	pfile, err := os.Open(file)
	if err != nil {
		return false
	}

	bucket := idx_cfg.bucket
	contenttype := "application/ocet-stream"
	_, err = c.PutObject(
		&s3.PutObjectInput{
			Bucket:      &bucket,
			Key:         &key,
			Body:        aws.ReadSeekCloser(pfile),
			ContentType: &contenttype,
		},
	)

	if err != nil {
		return false
	}

	log.Info(fmt.Sprintf("[upload flv] bucket: %s key: %s file: %s\n", bucket, key, file))

	return true
}
func runTests(t *testing.T, svc *s3.S3, tests []s3BucketTest) {
	for _, test := range tests {
		req, _ := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &test.bucket})
		req.Build()
		assert.Equal(t, test.url, req.HTTPRequest.URL.String())
	}
}
예제 #3
0
파일: gout.go 프로젝트: gnolizuh/gout
func ks3_mp4_merge(c *s3.S3, idx_file IndexFileT, idx_cfg IndexConfigT) bool {

	if len(idx_cfg.files) == 0 || len(idx_cfg.vdoid) == 0 {
		return true
	}

	files := ""
	for i := 1; i < len(idx_cfg.files); i++ {
		enckey := fmt.Sprintf("%s:record/%s/%s/%s/%s", idx_cfg.bucket, idx_file.app, idx_file.name, idx_file.time, idx_cfg.files[i])
		encstr := base64.StdEncoding.EncodeToString([]byte(enckey))
		if len(files) > 0 {
			files = fmt.Sprintf("%s&file=%s", files, encstr)
		} else {
			files = fmt.Sprintf("file=%s", encstr)
		}
	}

	bucket := idx_cfg.bucket
	srckey := fmt.Sprintf("record/%s/%s/%s/%s", idx_file.app, idx_file.name, idx_file.time, idx_cfg.files[0])
	dstkey := fmt.Sprintf("%s.mp4", idx_cfg.vdoid)
	command := fmt.Sprintf("tag=avconcat&f=mp4&mode=2&%s|tag=saveas&bucket=%s&object=%s", files, bucket, base64.StdEncoding.EncodeToString([]byte(dstkey)))
	contenttype := "application/ocet-stream"
	notifyurl := "http://10.4.23.113/test"

	log.Info(fmt.Sprintf("[merge flvs to mp4] bucket: %s srckey: %s dstkey: %s command: %s\n", bucket, srckey, dstkey, command))

	_, err := c.PutAdp(
		&s3.PutAdpInput{
			Bucket:      &bucket,
			Key:         &srckey,
			ContentType: &contenttype,
			Command:     &command,
			NotifyUrl:   &notifyurl,
		},
	)

	if err != nil {
		return false
	}

	return true
}