Created
December 14, 2021 18:18
-
-
Save harshalbhakta/dcc67a99591e7b591a4bcced0ceb2925 to your computer and use it in GitHub Desktop.
Faraday upload to S3 using Presigned URL
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 'faraday' | |
# Amazon S3 presinged url | |
url = "https://<bucket-name>.s3.amazonaws.com/path-to-file/1.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZTZBLMH3LBZ3WP5M%2F20211214%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211214T170722Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=d5929354744cb5d20102d92496c3b9e24a71dfd75535f4eee371979c2636f473" | |
response = Faraday.new(url).put("/path-to-file/1.txt") do |req| | |
req.body = File.binread("/Users/harshal/Temp/Trash/6.txt") | |
end | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment