Skip to content

Commit

Permalink
Fix replace file #4
Browse files Browse the repository at this point in the history
  • Loading branch information
silentsokolov committed May 1, 2018
1 parent bf3d193 commit 9429c3b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vimeo/videos.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ func (v Video) GetID() int {
// UploadVideoRequest specifies the optional parameters to the
// uploadVideo method.
type UploadVideoRequest struct {
Upload *Upload `json:"upload,omitempty"`
FileName string `json:"file_name"`
Upload *Upload `json:"upload,omitempty"`
}

func listVideo(c *Client, url string, opt ...CallOption) ([]*Video, *Response, error) {
Expand Down Expand Up @@ -304,6 +305,7 @@ func uploadVideo(c *Client, method string, url string, file *os.File) (*Video, *
}

reqUpload := &UploadVideoRequest{
FileName: file.Name(),
Upload: &Upload{
Approach: "tus",
Size: stat.Size(),
Expand Down Expand Up @@ -660,8 +662,8 @@ func (s *VideosService) ListRelatedVideo(vid int, opt ...CallOption) ([]*Video,
//
// Vimeo API docs: https://developer.vimeo.com/api/playground/videos/%7Bvideo_id%7D/files
func (s *VideosService) ReplaceFile(vid int, file *os.File) (*Video, *Response, error) {
u := fmt.Sprintf("videos/%d/files", vid)
video, resp, err := uploadVideo(s.client, "PUT", u, file)
u := fmt.Sprintf("videos/%d/versions", vid)
video, resp, err := uploadVideo(s.client, "POST", u, file)

return video, resp, err
}

0 comments on commit 9429c3b

Please sign in to comment.