Background
I am trying to generate a presigned url
which I can send to a react frontend. However I am struggling to generate a presigned url with ex_aws_s3
.
Dependencies
{:ex_aws, "~> 2.1.2"},
{:ex_aws_s3, "~> 2.0"},
{:hackney, "~> 1.9"},
{:sweet_xml, "~> 0.6"}
Shell
source .env
iex -S mix phx.server
IEX code
bucket = "fls-bm-app"
path = "/place_image/"
query_params = [{"ContentType", "image/png"}, {"ACL", "public-read"}]
presign_options = [virtual_host: true, query_params: query_params]
ExAws.Config.new(:s3)
|> ExAws.S3.presigned_url(:put, bucket, path, presign_options)
This returns a the following url
https://fls-bm-app.s3.amazonaws.com/place_image/?ACL=public-read&ContentType=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA5BRXG4R66NZ6MWLO%2F20220205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220205T200722Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=63de6df3730ea5a70c73035
When trying to push a file from the frontend to the above url it creates the folder /place_image/
only, but it doesn’t upload the file.
I am stumped as to where to go from here.