Skip to content

Instantly share code, notes, and snippets.

@mvasin
Created November 5, 2017 06:15
Show Gist options
  • Save mvasin/e69aa811b8ab1dcab1de44c2796fda41 to your computer and use it in GitHub Desktop.
Save mvasin/e69aa811b8ab1dcab1de44c2796fda41 to your computer and use it in GitHub Desktop.
require 'shrine'
require 'shrine/storage/s3'
S3_OPTIONS = {
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
region: 'eu-central-1',
bucket: ENV.fetch('AWS_BUCKET')
}.freeze
Shrine.storages = {
cache: Shrine::Storage::S3.new(
prefix: 'cache', upload_options: { acl: 'private' }, **S3_OPTIONS
),
store: Shrine::Storage::S3.new(
prefix: 'store', upload_options: { acl: 'public-read' }, **S3_OPTIONS
)
}
# uploader = Shrine.new(:store)
# uploaded_file = uploader.upload(File.open('input/hello.txt'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment