Skip to content

Instantly share code, notes, and snippets.

@pgib pgib/Gemfile

Created Dec 14, 2018
Embed
What would you like to do?
Sign an S3 URL
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'aws-sdk'
#!/usr/bin/env ruby
# vim ft=ruby
require 'bundler'
Bundler.setup
require 'aws-sdk'
client = Aws::S3::Client.new(region: 'us-west-2')
object = Aws::S3::Object.new(client: client, bucket_name: ENV['bucket'], key: ARGV[0])
if object.size > 0
puts object.presigned_url(:get, expires_in: 604800)
else
puts "#{ARVG[0]} not found."
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.