Skip to content

Commit

Permalink
feat(vimeo): upload video as interface
Browse files Browse the repository at this point in the history
  • Loading branch information
silentsokolov committed Apr 17, 2018
1 parent 28b9497 commit 79ee5fd
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 779 deletions.
15 changes: 0 additions & 15 deletions Gopkg.lock

This file was deleted.

34 changes: 0 additions & 34 deletions Gopkg.toml

This file was deleted.

34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "github.com/silentsokolov/go-vimeo/vimeo"


func main() {
client := vimeo.NewClient(nil)
client := vimeo.NewClient(tokenContext, nil)

// Specific optional parameters
cats, _, err := client.Categories.List(OptPage(1), OptPerPage(2), OptFields([]string{"name"}))
Expand All @@ -36,7 +36,7 @@ func main() {
)
tc := oauth2.NewClient(oauth2.NoContext, ts)

client := vimeo.NewClient(tc)
client := vimeo.NewClient(tc, nil)

cats, _, err := client.Categories.List()
}
Expand Down Expand Up @@ -105,16 +105,44 @@ func main() {

### Upload video ###

Since the release of Vimeo API version 3.4 used to unload the video the [tus protocol](https://tus.io/). Necessary to implement the process manually. You can use the implementation of [tus protocol on golang](https://github.com/eventials/go-tus).

```go
import (
"os"

"golang.org/x/oauth2"
"github.com/silentsokolov/go-vimeo/vimeo"

tus "github.com/eventials/go-tus"
)

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)
if err != nil {
return err
}

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

return uploader.Upload()
}

func main() {
client := ...
config := vimeo.Config{
Uploader: &Uploader{},
}

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

filePath := "/Users/user/Videos/Awesome.mp4"

f, _ := os.Open(filePath)
Expand Down
26 changes: 0 additions & 26 deletions vendor/github.com/eventials/go-tus/.gitignore

This file was deleted.

18 changes: 0 additions & 18 deletions vendor/github.com/eventials/go-tus/.travis.yml

This file was deleted.

9 changes: 0 additions & 9 deletions vendor/github.com/eventials/go-tus/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/eventials/go-tus/LICENSE

This file was deleted.

62 changes: 0 additions & 62 deletions vendor/github.com/eventials/go-tus/README.md

This file was deleted.

Loading

0 comments on commit 79ee5fd

Please sign in to comment.