wlminimal
How to get a link(url) from uploaded image in Amazon S3
Hi!
Now I am trying to upload image using ex_aws for Amazon AWS S3
Here is my code
def upload_file_to_S3(bucket_name, s3_filename, file_binary) do
S3.put_object(bucket_name, s3_filename, file_binary, [{:acl, :public_read}])
|> ExAws.request()
end
and I hope(?) it returns with link(uploaded image url) but it didn’t return it
This is first time using ex_aws, and trying to find docs about it but can’t find it.
How can I get an upload image url like " https://s3-us-west-1.amazonaws.com/text-marketing/03da408158584cd38a51aea77754d86c.jpg"
so I can use it in html ‘a’ tag or save it to the database.
Marked As Solved
joaquinalcerro
You can find a example here:
defmodule Epr.Services.AwsS3 do
def put_object(bucket, filename, binary_file, opts \\ []) do
ExAws.S3.put_object(bucket, filename, binary_file, opts)
|> ExAws.request()
end
def delete_object(bucket, filename) do
ExAws.S3.delete_object(bucket, filename)
|> ExAws.request()
end
def presigned_url(
method,
bucket,
filename,
config \\ ExAws.Config.new(:s3),
opts \\ [expires_in: 7200]
) do
{:ok, url} = ExAws.S3.presigned_url(config, method, bucket, filename, opts)
url
end
end
4
Popular in Questions
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
Hello,
I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these
buyer = %{
id: ...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Other popular topics
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New







