Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix field #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/services/job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (j *JobService) performUpload() error {
videoUpload := NewVideoUpload()
videoUpload.OutputBucket = os.Getenv("outputBucketName")
videoUpload.VideoPath = os.Getenv("localStoragePath") + "/" + j.VideoService.Video.ID
videoUpload.Prefix = j.VideoService.Video.Prefix
concurrency, _ := strconv.Atoi(os.Getenv("CONCURRENCY_UPLOAD"))
doneUpload := make(chan string)

Expand Down
5 changes: 3 additions & 2 deletions application/services/upload_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

type VideoUpload struct {
Paths []string
Prefix string
VideoPath string
OutputBucket string
Errors []string
Expand All @@ -29,15 +30,15 @@ func (vu *VideoUpload) UploadObject(objectPath string, client *storage.Client, c
// [0] caminho/x/b/
// [1] arquivo.mp4
path := strings.Split(objectPath, os.Getenv("localStoragePath")+"/")

f, err := os.Open(objectPath)
if err != nil {
return err
}

defer f.Close()

wc := client.Bucket(vu.OutputBucket).Object(path[1]).NewWriter(ctx)
wc := client.Bucket(vu.OutputBucket).Object(vu.Prefix + "/" +path[1]).NewWriter(ctx)
wc.ACL = []storage.ACLRule{{Entity: storage.AllUsers, Role: storage.RoleReader}}

if _, err = io.Copy(wc, f); err != nil {
Expand Down
1 change: 1 addition & 0 deletions domain/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type Video struct {
ID string `json:"encoded_video_folder" valid:"uuid" gorm:"type:uuid;primary_key"`
ResourceID string `json:"resource_id" valid:"notnull" gorm:"type:varchar(255)"`
Prefix string `json:"prefix" valid:"optional" gorm:"type:varchar(255)"`
FilePath string `json:"file_path" valid:"notnull" gorm:"type:varchar(255)"`
CreatedAt time.Time `json:"-" valid:"-"`
Jobs []*Job `json:"-" valid:"-" gorm:"ForeignKey:VideoID"`
Expand Down