socketry/multipart-post

Errno::ENOENT in multipart-post-1.0.1/lib/parts.rb:42

Closed this issue · 3 comments

when POST a.jpg to server with new name 'a'.
it will raise:

/home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/parts.rb:42:in `size': No such file or directory - 2 (Errno::ENOENT)
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/parts.rb:42:in`initialize'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/parts.rb:5:in `new'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/parts.rb:5:in`new'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/multipartable.rb:6:in `initialize'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/composite_io.rb:76:in`map'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/multipartable.rb:6:in `each'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/multipartable.rb:6:in`map'
        from /home/gavin_kou/local/lib/ruby/gems/1.8/gems/multipart-post-1.0.1/lib/multipartable.rb:6:in `initialize'

in parts.rb line 41. change from:

file_length = io.respond_to?(:length) ?  io.length : File.size(io.local_path)

to

file_length = io.respond_to?(:length) ?  io.length : File.size(io.path)

it works fine.

other side. looks when a file size is zero, it raise the same exception also.

Do you mind trying this again on the latest 2.0 release and let me know if this is still a problem?

Despite the documentation, it's not possible to construct a FilePart from an IO instance, you need to wrap it in an UploadIO first.