How to get image capture date and video duration when uploading files using SWFUpload and Paperclip
Posted
by Hatem
on Stack Overflow
See other posts from Stack Overflow
or by Hatem
Published on 2010-04-14T16:31:08Z
Indexed on
2010/04/14
16:43 UTC
Read the original article
Hit count: 458
Hi Guys,
I'm using SWFUpload and Paperclip on Rails 2.3.5 to upload images and videos. How can I store the capture date of images and duration of videos?
The following works correctly in irb:
irb(main):001:0> File.new('hatem.jpg').mtime
=> Tue Mar 09 16:56:38 +0200 2010
But when I try to use Paperclip's before_post_process:
before_post_process :get_file_info
def get_file_info
puts File.new(self.media.to_file.path).mtime # =>Wed Apr 14 18:36:22 +0200 2010
end
I get the current date instead of the capture date. How can I fix this? Also, how can I get the video duration and store it with the model?
Thank you.
© Stack Overflow or respective owner