Skip to content

Commit

Permalink
Handle empty i_stream in chunked uploader start call.
Browse files Browse the repository at this point in the history
  • Loading branch information
simi committed Nov 13, 2018
1 parent 42b597f commit e04aed9
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/dropbox_api/chunked_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def initialize(client, path, i_stream, options = {})

def start
chunk = @i_stream.read @chunk_size
chunk = "" if chunk.nil?

@cursor = @client.upload_session_start chunk
end
Expand Down
14 changes: 14 additions & 0 deletions spec/chunked_uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ module DropboxApi
@client = DropboxApi::Client.new
end

it 'uploads a empty string', :cassette => "chunked_uploader/success_with_empty_string" do
content = StringIO.new("")

uploader = DropboxApi::ChunkedUploader.new(@client, "#{path_prefix}/new_file.txt", content, {
:chunk_size => 4
})
uploader.start
uploader.upload
file_data = uploader.finish

expect(file_data).to be_a(DropboxApi::Metadata::File)
expect(file_data.name).to eq('new_file.txt')
end

it 'uploads a file', :cassette => "chunked_uploader/success" do
content = File.open(File.join(DropboxScaffoldBuilder.fixtures_path, "file.txt"))

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e04aed9

Please sign in to comment.