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

Problems doing file uploads #21

Closed
terrorobe opened this issue Apr 9, 2012 · 5 comments
Closed

Problems doing file uploads #21

terrorobe opened this issue Apr 9, 2012 · 5 comments

Comments

@terrorobe
Copy link

Hi,

it seems as if the file reader for the multi-part post in Github::Repos::Downloads#upload isn't hooked up correctly.

      'file'                  => prepend_at_for(filename.to_s)
[..]
  def prepend_at_for(file)
    /^@.*/ =~ file ? '@' + file : file
  end

This will never prepend an @ unless it already exists for the filename. And @ doesn't seem to be the right way to instruct Farady to stream file content during a request anyhow.

When replacing this with

      'file'                  => Faraday::UploadIO.new(filename, 'application/octet-stream')

the Faraday object gets mangled in Github::Request#request:

      request.body = MultiJson.encode(_process_params(params)) unless params.empty?

next to the fact that S3 doesn't want it's values as JSON in the first place: http://developer.github.com/v3/repos/downloads/#create-a-new-download-part-2-upload-file-to-s3

After changing this to:

      request.body = _process_params(params) unless params.empty?

I'm getting a

undefined method `instance_values' for #<File:0x000000013365c0>

and this is where I'm stopping since my Ruby-fu only takes me so far.

@piotrmurach
Copy link
Owner

Hi Michael,

I will look into this. I must admit I've only done isolated tests for this part and haven't done live request for file upload. The logic for 'prepend_at_for' is most embarrassing:) In the meantime if you succeed cracking the issue please submit a patch.

@piotrmurach
Copy link
Owner

Ok, I've implemented this feature and tested on live repository, all should work for ruby 1.8 and 1.9. Please grab the newest release of github_api 0.4.10. Sorry for the wait.

@pangratz
Copy link
Contributor

@peter-murach thank you VERY much!!

@terrorobe
Copy link
Author

@peter-murach Thanks, just tested it - works like a charm!

@piotrmurach
Copy link
Owner

@terrorobe Awesome!

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

3 participants