Created
November 5, 2017 06:16
-
-
Save mvasin/7c9e7f678bc40bb9957a601c42e60861 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
require 'roda' | |
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 = { | |
do_cache: Shrine::Storage::S3.new( | |
prefix: 'cache', upload_options: { acl: 'private' }, **S3_OPTIONS | |
), | |
do_store: Shrine::Storage::S3.new( | |
prefix: 'store', upload_options: { acl: 'public-read' }, **S3_OPTIONS | |
) | |
} | |
# :nodoc: | |
class App < Roda | |
route do |r| | |
r.get do | |
<<-HEREDOC | |
<html> | |
<body> | |
<form method="post"> | |
<input type="file"> | |
<input type="submit"> | |
</form> | |
</body> | |
</html> | |
HEREDOC | |
end | |
r.post do | |
'post request' | |
end | |
end | |
end | |
run App.freeze.app | |
# 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