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

fix update_with_media #525

Closed
wants to merge 1 commit into from
Closed

fix update_with_media #525

wants to merge 1 commit into from

Conversation

stve
Copy link
Collaborator

@stve stve commented Feb 1, 2014

This turned out to be easier than I thought it'd be. update_with_media is fairly well tested so I'm not sure additional tests are necessary as these changes are below the surface. I'm happy to add some if you think it's needed.

* send multipart/form-data header
* send requests to upload.twitter.com
@stve
Copy link
Collaborator Author

stve commented Feb 1, 2014

I should also mention mention that i've successfully tested this to verify it works.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling a902914 on update_with_media into 88d7b19 on master.

@sferik
Copy link
Owner

sferik commented Feb 1, 2014

I believe this is already working in master (before your patch). Does this patch fix the issue in the http branch?

@stve
Copy link
Collaborator Author

stve commented Feb 1, 2014

My mistake, I thought the http branch had been merged, will check and let you know.

@sferik
Copy link
Owner

sferik commented Feb 1, 2014

The http branch removes the #middleware interface, so it will require a major version bump (6.0.0). Since version 0.5.0 of the http gem is not yet production ready and I plan to push more 5.x releases, I haven’t merged it yet.

I’ve asked @tarcieri to provide a nicer interface (or at least an example) of how to perform a multipart post using the http gem in httprb/http#73.

Also, the HTTP::Response#parse method was temporarily removed, so I’ve hacked it back in, just to make tests pass in the http branch.

You’ll need to update the http dependency in your Gemfile:

gem 'http', :git => 'https://github.com/sferik/http.git', :branch => 'parse'

You may also wish to use my http branch of webmock, which silences deprecation warnings from the HTTP gem at master.

gem 'webmock', :git => 'https://github.com/sferik/webmock.git', :branch => 'http'

@stve
Copy link
Collaborator Author

stve commented Feb 1, 2014

Thanks! I was just figuring out what versions you were using as pointing at HEAD on http resulted in nearly the entire test suite failing due to HTTP::Response#parse missing as you indicated above.

@justspamjustin
Copy link

I am trying to use update_with_media and I'm getting a Missing or Invalid url parameter. error.
I'm opening a file from disk and trying to use update_with_media like this:

file = File.read("./public/uploads/#{image_name}").encode!('UTF-8', 'UTF-8', :invalid => :replace)
@client.update_with_media(post.content, file)

@sferik
Copy link
Owner

sferik commented Feb 3, 2014

@justspamjustin update_with_media takes a Ruby File object (technically, any IO) as its second argument.

file = File.new("./public/uploads/#{image_name}")
@client.update_with_media(post.content, file)

@justspamjustin
Copy link

@sferik Thanks. I'm still a bit new to ruby.

@sferik
Copy link
Owner

sferik commented Feb 3, 2014

@justspamjustin No problem. In the future, please use the mailing list or Stack Overflow for support questions.

You may also be interested in reviewing the documentation for update_with_media and the example on posting updates.

@sferik sferik force-pushed the master branch 3 times, most recently from 5b495e9 to 5c57042 Compare October 9, 2014 00:21
@sferik sferik force-pushed the master branch 12 times, most recently from 42b2586 to c326a83 Compare November 10, 2014 08:52
@sferik sferik closed this Nov 11, 2014
@stve stve deleted the update_with_media branch December 23, 2014 14:42
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

Successfully merging this pull request may close these issues.

None yet

4 participants