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
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
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lis...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
I'm trying to create a simple query to select distinct values from a column. If I only use select and distinct I get back a list of uniqu...
New
Other popular topics
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
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
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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







