This file contains 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
# config/initializers/paperclip.rb | |
# If you want to disable paperclip attachments to S3 in the development environment, | |
# remove the comments from the "if" condition below and restart the server. | |
#if Rails.env.staging? || Rails.env.production? | |
Paperclip::Attachment.default_options[:storage] = :s3 | |
Paperclip::Attachment.default_options[:s3_credentials] = { | |
:bucket => "app-#{Rails.env}", | |
:access_key_id => '<ACCESS_KEY_ID>', | |
:secret_access_key => '<SECRET_ACCESS_KEY>' |
This file contains 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
require 'aws-sdk' | |
s3 = Aws::S3::Resource.new( | |
region: 'us-east-1', | |
credentials: Aws::InstanceProfileCredentials.new() | |
) | |
bucket = s3.bucket('my-daily-backups') | |
file = (DateTime.now).strftime("%Y.%m.%d-backup") | |
if bucket.object(file).exists? |