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

File upload does not support remote urls anymore #610

Closed
remi-stripe opened this issue Dec 5, 2017 · 4 comments
Closed

File upload does not support remote urls anymore #610

remi-stripe opened this issue Dec 5, 2017 · 4 comments

Comments

@remi-stripe
Copy link
Contributor

remi-stripe commented Dec 5, 2017

If you try to upload a file via the API with a remote URL, you get back the error invalid hash. This used to work on 1.X (up to 1.58.0) but broke on 2.0.0 (real crash) and then another fix in 2.0.1 that lead to the current error. It also seems to only work with JPG files for that matter and crashed even on 1.X for PNG or SVG.

Example code to reproduce

require "stripe"
require 'open-uri'
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

id_file = URI("https://i.pinimg.com/736x/1e/b7/d9/1eb7d9a9f9e2225479f28b3846ae028d--carolina-blue-blue-stripes.jpg").open

file_upload = Stripe::FileUpload.create(purpose: 'identity_document', file: id_file)
puts file_upload.id
@brandur-stripe
Copy link
Contributor

Fix pushed in 3.8.1. Thanks @ob-stripe @remi-stripe!

@AlexanderFisenko
Copy link

AlexanderFisenko commented Apr 11, 2019

Hey guys!
I experience same problem when trying to upload a file via the API with a remote URL and get back the error "invalid hash". My current version is 4.9, but have already tried 4.8.1 and 4.12.0.

Here is the output:

Exception: Stripe::InvalidRequestError: (Status 400) (Request req_WUYm5h0NwJBBv0) Invalid hash
0: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:343:in `handle_error_response'
 1: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:294:in `rescue in execute_request_with_rescues'
 2: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:257:in `execute_request_with_rescues'
 3: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:177:in `execute_request'
 4: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/api_operations/request.rb:19:in `request'
 5: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/api_operations/create.rb:7:in `create'
 6: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/file.rb:31:in `create'
 7: (pry):5:in `upload_to_stripe'
 8: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `eval'
 9: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `evaluate_ruby'
10: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:355:in `handle_line'
11: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:274:in `block (2 levels) in eval'
12: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `catch'
13: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:273:in `block in eval'
14: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `catch'
15: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:272:in `eval'
16: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:77:in `block in repl'
17: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:67:in `loop'
18: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:67:in `repl'
19: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:38:in `block in start'
20: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/input_lock.rb:59:in `__with_ownership'
21: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/input_lock.rb:77:in `with_ownership'
22: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:38:in `start'
23: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/repl.rb:13:in `start'
24: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_class.rb:200:in `start'
25: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-byebug-3.7.0/lib/byebug/processors/pry_processor.rb:117:in `block in resume_pry'
26: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-byebug-3.7.0/lib/byebug/processors/pry_processor.rb:30:in `block (2 levels) in run'
27: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/byebug-11.0.0/lib/byebug/helpers/eval.rb:94:in `allowing_other_threads'
28: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-byebug-3.7.0/lib/byebug/processors/pry_processor.rb:30:in `block in run'
29: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/pry-byebug-3.7.0/lib/byebug/processors/pry_processor.rb:29:in `catch'
Caused by: Faraday::ClientError: the server responded with status 400


0: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/response/raise_error.rb:13:in `on_complete'
 1: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/response.rb:9:in `block in call'
 2: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/response.rb:61:in `on_complete'
 3: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/response.rb:8:in `call'
 4: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/request/url_encoded.rb:15:in `call'
 5: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/request/multipart.rb:15:in `call'
 6: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
 7: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
 8: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:178:in `block in execute_request'
 9: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:260:in `execute_request_with_rescues'
10: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/stripe_client.rb:177:in `execute_request'
11: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/api_operations/request.rb:19:in `request'
12: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/api_operations/create.rb:7:in `create'
13: /Users/hammer/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/stripe-4.12.0/lib/stripe/file.rb:31:in `create'
14: (pry):5:in `upload_to_stripe'

@ob-stripe
Copy link
Contributor

Hi @AlexanderFisenko. Can you open a new issue for this, and share the exact code you're using to send your request?

@AlexanderFisenko
Copy link

Hi @ob-stripe. Done #761

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

4 participants