Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Content-Length when #upload passed string #39

Closed
ntippie opened this issue Feb 3, 2018 · 4 comments
Closed

Incorrect Content-Length when #upload passed string #39

ntippie opened this issue Feb 3, 2018 · 4 comments

Comments

@ntippie
Copy link

ntippie commented Feb 3, 2018

I noticed that when the #upload method is given a string (like the result of IO.read), the uploaded file is not the correct size.

result1 = service.upload('/test1.png', IO.read('/tmp/test.png'))
result1.size
=> 6208

File.open('/tmp/test.png') do |file|
  result2 = service.upload('/test2.png', file)
end
result2.size
=> 6477

File.size('/tmp/test.png')
=> 6477

I compared the content of the two files and they are identical up until test1's premature end (it is missing the last 269 bytes).

I traced the issue to here. I believe the first priority method to call should be #bytesize, which will get the proper size in bytes. I'd be happy to submit a PR if you agree.

@Jesus
Copy link
Owner

Jesus commented Feb 6, 2018

That's interesting, thanks for your report.

I can't look into it with detail right now but will try to reproduce it this week.

@Jesus
Copy link
Owner

Jesus commented Feb 9, 2018

I'm a bit confused, I think you're passing the path to the local file rather than the file contents, as the method expects. This is documented here: http://www.xuuso.com/dropbox_api/DropboxApi/Client.html#upload-instance_method

What's the value of save_path in your first example?

If you pass the path to a file, this'll be saved in Dropbox as the content of your file.

@ntippie
Copy link
Author

ntippie commented Feb 11, 2018

I'm sorry, I documented it incorrectly. I've updated the original post.

@ntippie ntippie changed the title Incorrect Content-Length when #upload passed path string Incorrect Content-Length when #upload passed string Feb 12, 2018
@Jesus Jesus closed this as completed in a215ae7 Feb 13, 2018
@Jesus
Copy link
Owner

Jesus commented Feb 13, 2018

I see now, thanks for your report!

I'll release a new version including this fix as soon as I get a chance, over the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants