socketry/multipart-post

Errno::ENOENT: No such file or directory - local.path

Opened this issue · 4 comments

I'm using Faraday which requires this gem as a dependency. When I try this code in the rails console

conn = Faraday.new('http://localhost:3000') do |far|
  far.request :multipart
  far.request :url_encoded
end
params = {}
params[:user] = {:avatar => Faraday::UploadIO.new('sample.jpg', 'image/jpeg') }
response = conn.put('/users', params)

I get the following error:

Errno::ENOENT: No such file or directory - local.path
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/multipart-post-1.1.5/lib/parts.rb:51:in `size'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/multipart-post-1.1.5/lib/parts.rb:51:in `initialize'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/multipart-post-1.1.5/lib/parts.rb:11:in `new'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/multipart-post-1.1.5/lib/parts.rb:11:in `new'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:37:in `block in create_multipart'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:57:in `call'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:57:in `block in process_params'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `each'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `inject'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `process_params'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:55:in `block in process_params'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `each'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `inject'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:47:in `process_params'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:36:in `create_multipart'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:11:in `block in call'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/url_encoded.rb:20:in `match_content_type'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/request/multipart.rb:7:in `call'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in `run_request'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/faraday-0.8.4/lib/faraday/connection.rb:99:in `put'
    from (irb):60                               
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
    from /Users/jeremy/.rvm/gems/ruby-1.9.3-p362/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'1.9.3p362 :061 >

Using version 1.1.5

Is this still an issue on ruby 2.0+ ?

lol. I don't even remember posting this issue. The app I was using this for doesn't even exist 😂

@jwoertink It's okay, even though the issue is old, it's never been triaged, so I'm just going through all issues to try and at least get a handle on what the status is currently.

I occurred the same issue. I resolved it as below.

File.open('sample.jpg') do |file|
  params = {}
  params[:user] = {:avatar => UploadIO.new(file, 'image/jpeg', 'filename.jpg') }
  response = conn.put('/users', params)
end

faraday v0.17.3