开发者

Ruby EXIFR can not find file

开发者 https://www.devze.com 2023-02-01 06:37 出处:网络
I am trying to use the EXIF reader and I continue to get the error \"Errno::ENOENT: No such file or directory\"

I am trying to use the EXIF reader and I continue to get the error "Errno::ENOENT: No such file or directory"

I have checked and the file most certainly exists in the location I am directing it to:

<%= EXIFR::JPEG.new('/system/datas/5/original/IMG_0011.JPG').date_time %>
开发者_如何学Go

(This is where paperclip puts the files upon uploading)

Any ideas on why I continue to receive this error. I think the problem may not be finding the file but that error is masking the real issue.

I need to retrieve the EXIF data from picture files. Any other ideas are welcome. I am using paperclip to upload files.

Thanks!


The path you provided to EXIFR is a URL, not a path on the system. Try it:

$ ls /system/datas/5/original/IMG_0011.JPG

The file is stored in the public directory of your rails app, so do something like:

EXIFR::JPEG.new(Rails.root.join('public', '/system/datas/5/original/IMG_0011.JPG')).date_time

But paperclip also provides a method to access the path, and that is through the path method:

@model.data.path


Does this work for you

<%= EXIFR::JPEG.new(Rails.root.join('public/system/datas/5/original/IMG_0011.JPG')).date_time %>
0

精彩评论

暂无评论...
验证码 换一张
取 消