Skip to content

Instantly share code, notes, and snippets.

@bradymholt
Last active May 9, 2022 18:35
Show Gist options
  • Save bradymholt/0af96461ece3fccb548a9546001c6ecc to your computer and use it in GitHub Desktop.
Save bradymholt/0af96461ece3fccb548a9546001c6ecc to your computer and use it in GitHub Desktop.
Generate presigned S3 upload URL with aws-sdk-s3 in Ruby
resource = Aws::S3::Resource.new(client: Aws::S3::Client.new)
url = resource.bucket('my-bucket').object('myfolder/foo.txt').presigned_url(:put)
put url
curl -v --upload-file ./foo.txt "https://my-bucket.s3.amazonaws.com/myfolder/foo.txt?X-Amz-Algorithm=<snip>&X-Amz-Credential=<snip>%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=<snip>&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=<snip>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment