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

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

Closed
jwoertink opened this issue Jan 30, 2013 · 4 comments
Closed

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

jwoertink opened this issue Jan 30, 2013 · 4 comments

Comments

@jwoertink
Copy link

I came across a weird error which at first I thought might be the multipart-post gem, but now I'm not so sure.

socketry/multipart-post#23

When I make a Faraday::UploadIO object, it sets my local_path to "local.path"

{:user=>{:avatar=>#<UploadIO:0x007fd2cf69cb08 @content_type="image/jpeg", @original_filename="local.path", @local_path="local.path", @io=#<Pathname:/Users/jeremy/Sites/tabeso/spec/fixtures/images/sample.jpg>, @opts={}>}}

When the multipart-post gem calls File.size, it throws the error. Is there something I should look for?

@technoweenie
Copy link
Member

This is where multipart-post sets it: https://github.com/nicksieger/multipart-post/blob/master/lib/composite_io.rb#L80-L82

So, it looks like your io object doesn't respond to #path. How should Faraday handle that better? I wonder if we can replace File.size with just #size?

@jwoertink
Copy link
Author

hmm. I'm not sure. It was suggested to me to use Faraday::UploadIO.new(File.open('sample.jpg'), 'image/jpeg') but that just throws the error redundant UTF-8 sequence.

@mistersourcerer
Copy link
Contributor

I was looking into the multipart-post gem, apparently they recognised the problem and fixed it (https://github.com/nicksieger/multipart-post/blob/master/lib/composite_io.rb#L80-L82), you guys think that Faraday should worry about it yet?
In case this is not a problem anymore, I was thinking if we can close the issue.

@mislav
Copy link
Contributor

mislav commented Dec 5, 2013

@ricardovaleriano That was added 3 years ago in socketry/multipart-post@abb5450 and was since then released.

@jwoertink Your problem might be because you passed a Pathname for the upload IO object.

I don't think we have a bug in Faraday here. I would love to see a reproducible failure. Until then, it's just wrong usage (which encoding problems are also a part of).

If someone wants to contribute docs for how to do file uploads with Faraday, the wiki is a good place to do that.

@mislav mislav closed this as completed Dec 5, 2013
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