Created
December 14, 2018 21:14
-
-
Save pgib/a1130d819f7bba48dbc40c426507d141 to your computer and use it in GitHub Desktop.
Sign an S3 URL
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
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
gem 'aws-sdk' |
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
#!/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