0

I am working on aa API that uploads video file to Vimeo using Go tus approach. I could get the video created but not able to find a way to include metadata parameters that can be used to specify the name of video etc.

I am using github.com/eventials/go-tus for tus protocol and github.com/silentsokolov/go-vimeo/vimeo for sending APi requests to vimeo upload. Any pointers or help to upload videos on vimeo using thier API would be great help.

package main

import (
    "fmt"
    "os"
    tus "github.com/eventials/go-tus"
    "github.com/silentsokolov/go-vimeo/vimeo"
    "golang.org/x/oauth2"
)

type Uploader struct{}

func (u Uploader) UploadFromFile(c *vimeo.Client, uploadURL string, f *os.File) error {
    tusClient, err := tus.NewClient(uploadURL, nil)
    if err != nil {
        return err
    }

    upload, err := tus.NewUploadFromFile(f)

    metdata := make(map[string]string)
    metdata["name"] = "Callout_Video"

    upload.Metadata = metdata
    uploader := tus.NewUploader(tusClient, uploadURL, upload, 0)

    return uploader.Upload()
}

func main() {

    config := vimeo.Config{
        Uploader: &Uploader{},
    }

    ts := oauth2.StaticTokenSource(
        &oauth2.Token{AccessToken: "xxxxxxxxx"},
    )
    tc := oauth2.NewClient(oauth2.NoContext, ts)

    client := vimeo.NewClient(tc, &config)

    filePath := "Test_Video.mp4"

    f, _ := os.Open(filePath)

    fmt.Println(f.Name())
    video, resp, _ := client.Users.UploadVideo("", f)

    fmt.Println(video.Name)
    fmt.Println(resp)
}
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
scagc
  • 1
  • 1
  • have you tried setting [this](https://github.com/silentsokolov/go-vimeo/blob/0c44125371594b1c3f08e257f8ed52811be6d82a/vimeo/videos.go#L75). – whitespace Jan 07 '21 at 12:06
  • As per the documentation "name" is the key for setting the title of the video. I didnt try the key you referred.. will try that, but I think the problem is with go-tus package that's not taking anything I populate in metadata of the upload. Here is my basic version of code just trying to upload a local video file to vimeo usin tus protocol. – scagc Jan 08 '21 at 18:22

0 Answers0