Created
April 22, 2010 05:07
-
-
Save michelson/374843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def move_to_s3 | |
temp_path = attachment.path | |
temp_file = attachment.to_file # Paperclips way of getting a File object for the attachment | |
# Save it as a regular attachment | |
# this will save to S3 | |
s3_upload = Upload.find(id) # Same db record but we need the S3 version | |
s3_upload.attachment = temp_file # reset the file - it will assume its a new file | |
s3_upload.save! # Paperclip will upload the file on save | |
# Delete the temporary file when we are done | |
temp_file.close | |
File.delete(temp_path) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment