Created
March 31, 2022 08:45
-
-
Save davorbadrov/9b4bb9ac591465ea55ea48ba48c341e7 to your computer and use it in GitHub Desktop.
S3 Upload Elixir ExAws
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
file = "test.txt" | |
File.write(file, "this is a test") | |
config = ExAws.Config.new(:s3, [ | |
region: "us-east-1", | |
access_key_id: "...", | |
secret_access_key: "..." | |
] | |
) | |
s3_bucket = "bucket name" | |
s3_key = "file_path_and_name.txt" | |
{:ok, _} = | |
file | |
|> ExAws.S3.Upload.stream_file() | |
|> ExAws.S3.upload(s3_bucket, s3_key) | |
|> ExAws.request(config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment