Walter Lee Davis
2013-Aug-09 21:15 UTC
Duplicating a Paperclip attachment without running processors?
I need to duplicate an object that has an attached Paperclip file. This file (depending on its file-type) may have two to four different styles, with separate file-processing stages required for each. Some of these involve transcoding in FFMPEG, so I would really rather not run the processors all over again, when the various re-coded versions already exist on S3. The naive thing (which I have done, and works) is simply to create a new object, open the original file from S3 using open-uri, and run the process over again. This works, but takes a long time, since some of these movie files are large and the processing steps to make thumbnails and poster frames are weighty. Searching for solutions on this, I came across the dup method, and I also saw a dup method on the Paperclip attachment when I inspected its methods. Before I go into a lengthy yak-shaving exercise here, can anyone point me to a simpler way to manage what I am trying to accomplish here? Essentially I want to duplicate a group of files in place on S3 (yes, I realize you can''t do that without copying them) but I want to skip all the processing steps and just duplicate the styles "manually". Thanks in advance, Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/930C9291-C70A-44B1-8ADE-932327D2D0CE%40wdstudio.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Walter Lee Davis
2013-Aug-12 16:13 UTC
Re: Duplicating a Paperclip attachment without running processors?
Replying to my own, since I posted after beer-thirty on Friday. On Aug 9, 2013, at 5:15 PM, Walter Lee Davis wrote:> I need to duplicate an object that has an attached Paperclip file. This file (depending on its file-type) may have two to four different styles, with separate file-processing stages required for each. Some of these involve transcoding in FFMPEG, so I would really rather not run the processors all over again, when the various re-coded versions already exist on S3. > > The naive thing (which I have done, and works) is simply to create a new object, open the original file from S3 using open-uri, and run the process over again. This works, but takes a long time, since some of these movie files are large and the processing steps to make thumbnails and poster frames are weighty. > > Searching for solutions on this, I came across the dup method, and I also saw a dup method on the Paperclip attachment when I inspected its methods. Before I go into a lengthy yak-shaving exercise here, can anyone point me to a simpler way to manage what I am trying to accomplish here? Essentially I want to duplicate a group of files in place on S3 (yes, I realize you can''t do that without copying them) but I want to skip all the processing steps and just duplicate the styles "manually".Here''s another thing I have found: http://blog.firsthand.ca/2011/07/ruby-script-to-duplicate-s3-bucket.html which is to duplicate an entire bucket. I''m not sure of my terminology here, is a bucket always the outermost container, or is it any level of "directory" in a named bucket? I''ve been reading the source of right_aws here: https://github.com/rightscale/right_aws/blob/master/lib/s3/right_s3.rb and there is a copy_key method that looks useful, but I am leery of creating a duplicate Paperclip object without involving Paperclip. Is the relationship between an attachment and all of its versions merely predicated on the file paths? Is there any metadata stored elsewhere that I would also need to duplicate? Thanks, Walter> > Thanks in advance, > > Walter > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/930C9291-C70A-44B1-8ADE-932327D2D0CE%40wdstudio.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E3A41515-A851-4094-AB11-C3FEF5A23597%40wdstudio.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.