Skip to content

Commit

Permalink
Fixed simple_upload for new API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Drinka committed May 28, 2012
1 parent 7dfb740 commit e1fda48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/vimeo/advanced/simple_upload/chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(task, data)

# Performs the upload via Multipart.
def upload
endpoint = "#{task.endpoint}&chunk_id=#{index}"
endpoint = "#{task.endpoint}"

response = task.oauth_consumer.request(:post, endpoint, vimeo.get_access_token, {}, {}) do |req|
req.set_content_type("multipart/form-data", { "boundary" => MULTIPART_BOUNDARY })
Expand All @@ -29,6 +29,8 @@ def io.original_filename; @original_filename; end
def io.content_type; "application/octet-stream"; end

parts = []
parts << Parts::ParamPart.new(MULTIPART_BOUNDARY, "ticket_id", task.id)
parts << Parts::ParamPart.new(MULTIPART_BOUNDARY, "chunk_id", index)
parts << Parts::FilePart.new(MULTIPART_BOUNDARY, "file_data", io)
parts << Parts::EpiloguePart.new(MULTIPART_BOUNDARY)

Expand All @@ -47,4 +49,4 @@ def io.content_type; "application/octet-stream"; end
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/vimeo/advanced/simple_upload/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def valid?

# Returns a hash of the sent chunks and their respective sizes.
def sent_chunk_sizes
Hash[chunks.map { |chunk| [chunk.id, chunk.size] }]
Hash[chunks.map { |chunk| [chunk.index.to_s, chunk.size] }]
end

# Returns a of Vimeo's received chunks and their respective sizes.
Expand All @@ -82,4 +82,4 @@ def received_chunk_sizes
end
end
end
end
end

0 comments on commit e1fda48

Please sign in to comment.