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

UploadError: Missing end boundary in multipart body. #167

Closed
scaryguy opened this issue May 26, 2013 · 12 comments
Closed

UploadError: Missing end boundary in multipart body. #167

scaryguy opened this issue May 26, 2013 · 12 comments

Comments

@scaryguy
Copy link

When I use standart upload method just the same as it exists in READ ME, I get this error:

client = YouTubeIt::Client.new(:username=>"USERNAME", :password=>"PASSWORD", :dev_key=>"DEV_KEY")
client.video_upload(File.open("/Users/scaryguy/sts_videos/youtube.mp4"), :title => "dfddftest",:description => "some description fdfdfdfd", :category => "People", :keywords => %w[cool blah test])
UploadError: Missing end boundary in multipart body.
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/bundler/gems/youtube_it-eb5058bd9379/lib/youtube_it/middleware/faraday_youtubeit.rb:27:in `on_complete'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/faraday-0.8.7/lib/faraday/response.rb:9:in `block in call'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/faraday-0.8.7/lib/faraday/response.rb:63:in `on_complete'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/bundler/gems/youtube_it-eb5058bd9379/lib/youtube_it/middleware/faraday_authheader.rb:17:in `call'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/faraday-0.8.7/lib/faraday/connection.rb:247:in `run_request'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/faraday-0.8.7/lib/faraday/connection.rb:112:in `post'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/bundler/gems/youtube_it-eb5058bd9379/lib/youtube_it/request/video_upload.rb:92:in `upload'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/bundler/gems/youtube_it-eb5058bd9379/lib/youtube_it/client.rb:117:in `video_upload'
    from (irb):4
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /Users/scaryguy/.rvm/gems/ruby-2.0.0-p0@sts/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
$ rails -v
Rails 3.2.13

P.S: I had told you, chebyte, that my boss would make a small donation last day. I'm sorry but I can't force my boss to make a donation for something which we can not even use. I couldn't use the gem since I met it.

@kylejginavan
Copy link
Owner

Sorry you are unable to use this gem. At this point it is probably best you use a different youtube gem @scaryguy. Since I'm unable to reproduce this I'm closing this issue. Please provide a failing test or a patch for us to look at.

@americos
Copy link

americos commented Jun 4, 2013

Hi @kylejginavan,

I just experience the same error as @scaryguy, same kind of simple test based on the readme file.
Here is the code I'm running (I removed user,pass,key, etc) : https://gist.github.com/americos/5709494

Using Ruby: 1.9.3p327

I would really appreciate if you can have a quick look, I don't know what I'm missing or doing wrong.

@facetoe
Copy link

facetoe commented Jun 18, 2013

I also encountered this error. Using: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]

I was attempting to upload a .avi file using the code in the readme.

@facetoe
Copy link

facetoe commented Jun 18, 2013

Just tried with a .mov file and also got the error. It's strange because last night it worked fine...

@chrosciu
Copy link

I investigated the issue. In my opinion problem is in the fact, that Faraday::Excon adapter tries to read body without passing buffer size (probably it assumes that body will be returned as a whole)

# TODO: support streaming requests
def read_body(env)
  env[:body].respond_to?(:read) ? env[:body].read : env[:body]
end

This goes to GreedyChainIO which assumes that default buffer size is 500k

class YouTubeIt::GreedyChainIO < DelegateClass(YouTubeIt::ChainIO)
  BIG_CHUNK = 512 * 1024 # 500 kb

  def read(any_buffer_size = nil)
    __getobj__.read(BIG_CHUNK)
  end

so it does not return more than 500k as a body to faraday (and body is cut in the half).

I made some tests - I tried to upload 600k video file to youtube and got topic error. Then I increased buffer size in GreedyChainIO to 1MB and upload was performed without any problems

However I have no idea how to fix this....

@kylejginavan
Copy link
Owner

@chrosciu well said and thank you. I will research this a bit more.

@chrosciu
Copy link

@kylejginavan: I prepared some fix both for this issue and #159.

neubloc@715a4dc

If you think it is ok, I can prepare pull request

@facetoe
Copy link

facetoe commented Jun 21, 2013

Thanks @kylejginavan, I'll give it a test right away!

@facetoe
Copy link

facetoe commented Jun 21, 2013

I just tested the fix @kylejginavan and it worked perfectly!

@chrosciu
Copy link

@facetoe : glad to hear it :)

@chebyte
Copy link
Collaborator

chebyte commented Jun 27, 2013

@chrosciu thanks! I going to put your fix!

@chebyte
Copy link
Collaborator

chebyte commented Jun 27, 2013

@ALL today we going to make the new realease with the fix!

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

6 participants