Hi Peops,
SO I am trying to use the “presign_url” method on the ex_aws_s3 package - which is essentially just the “ex_aws.Auth.presign_url”.
Long story short - regardless of what url I use or options… I just cannot get this function to play ball even with postman let alone trying to send data from the browser as a form object.
[https://imgur.com/zcRA3sm](response , headers and url1)
[https://imgur.com/TNeOHsD](response , headers and url2)
my function:
def presign_post_url(bucket_name, file_name, file_type_extension) do config = %
config = { region: "eu-west-1" }
ex_s3_client = ExAws.Config.new(:s3, config)
query_params = [
{ "Content-Type", "image/jpg"},
{'key', "profile-pictures/" <> file_name}
# { "content-length-range", "10\,10000000" }#max 10MB
]
presign_options = [virtual_host: false, query_params: query_params]
ExAws.S3.presigned_url(ex_s3_client, :post, "profile-pictures", file_name, presign_options)
end
The error I get - not matter how I construct the url with bucket_name/folder-path/differents3-url-structures, I always get:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>MethodNotAllowed</Code>
<Message>The specified method is not allowed against this resource.</Message>
<Method>POST</Method>
<ResourceType>OBJECT</ResourceType>
<RequestId>D0BA0AC513BE36D6</RequestId>
<HostId>NyzdUPLDzHnbkHzWxxcLjdGXOXkpmGOUU1KFIAPJ+vpIPEq0WWyZEerGq1xySG26qzPfKUg7l/o=</HostId>
</Error>
Cors on bucket:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
I am stumped, there’s another little issue - about getting the presign_url
method to play nicely with “content-length-range”, as it’s not a two value keyword list.
Any help or advice would be awesome!