AlchemistCamp

AlchemistCamp

Upload external files from URLs (automated, no front-end)

I’m looking for a good way to fetch files from URLs and upload them to an S3 bucket. I’ve seen a lot of posts here about uploads, but they’re generally focused on images uploaded by users via a form. The scenario I’m working on is an automated script fetching images from a file server and putting them onto S3.

I have a list of [img_url1, img_url2, img_url3, | _the_rest], and I want to fetch and upload all of those files to my S3 bucket. What’s a good way to go about it?

I’m using Phoenix, but AFIK, that’s probably not very relevant to this task.

Most Liked

achempion

achempion

Hey, Waffle author here.

You can do this via the Waffle library like this:

Avatar.store("http://example.com/file.png") #=> {:ok, "file.png"}

You only need to configure access for your S3 storage and create an uploader.

Please, feel free to ask if you’ll have any troubles.

LostKobrakai

LostKobrakai

I’ll essentially be using your prefered http client library to fetch the files and using your prefered aws library to push the data to S3. From there you could layer optimizations like streaming or parallelism on top if needed.

w0rd-driven

w0rd-driven

s3cmd and s3 have a sync command that can synchronize between buckets and regions but I don’t know if you can use it to sync between s3 compatible providers. It seems like a logical goal but configuring multiple providers isn’t something I’ve done to know if it’s possible.

GitHub - s3tools/s3cmd: Official s3cmd repo -- Command line tool for managing Amazon S3 and CloudFront services or sync — AWS CLI 1.27.145 Command Reference lists the aws cli. I’m not at my laptop atm to look at s3cmd’s output but it’s one of the more robust CLIs that seemingly covers everything I throw at it.

My coworker is in the process of synchronizing our entire bucket between local and another provider due to issues with digital ocean spaces. I’ll try to hit him up later today to see how he’s getting that done. It wouldn’t be Elixir but knowing his steps could be helpful to work backwards if you go down the http client route.

Where Next?

Popular in Questions Top

JorisKok
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
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
polypush135
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
mgjohns61585
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
rms.mrcs
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

We're in Beta

About us Mission Statement