Created
February 2, 2018 05:49
-
-
Save evadne/41c04d927b25ce1cf68e2f1fb851d349 to your computer and use it in GitHub Desktop.
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
defp prepare_signed_url({region, bucket, object}, friendly_name) do | |
config = ExAws.Config.new(:s3, %{region: region}) | |
encoded_name = URI.encode(friendly_name, fn | |
x when ?0 <= x <= ?9 -> true | |
x when ?A <= x <= ?Z -> true | |
x when ?a <= x <= ?z -> true | |
_ -> false | |
end) | |
options = [ | |
expires_in: 1800, | |
query_params: [{ | |
"response-content-disposition", | |
"attachment; filename*=UTF-8''#{encoded_name}" | |
}] | |
] | |
ExAws.S3.presigned_url(config, :get, bucket, object, options) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment