Liam_or

Liam_or

Local storage vs something like Amazon S3 for files?

Would it be more effective to store fixed media assets (like lessons, videos, or images that I’ve created and aren’t expected to grow dynamically) directly on the server’s local storage instead of using a third-party service like Amazon S3?

I’m not talking about static content served directly, but rather files that are read on client request, rendered, and sent dynamically via LiveView. Since the media is pre-created by me and doesn’t change often or grow due to user input, could storing and serving the content directly from the server simplify the process and potentially improve performance by avoiding the S3 → server → client flow? Also, phoenix is easily distributed, so I can use that to my advantage if I want to have the media closer to the client in future.

Most Liked Switch mode

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

It is the same whether using LiveView or otherwise. You gave records in your database usually that track what items exist and where on S3 they are stored. You then can use those records to also track authorization and access rules. If someone is allowed access to those records you use a library to generate a signed link. At that point it’s just a normal link and you put it in an img tag or whatever the normal HTML thing is.

D4no0

D4no0

If you simply want to let the user download the file/files it is as simple as creating a phoenix controller that will serve the binary, then generate a link in your liveviews, this is not only completely flexible (it’s extremely trivial also to make this work with s3), but you get the full benefit of filtering from your application who can access that dynamic link.

This is up to you how you want to implement it, with a phoenix controller implementing temporary URLs is trivial, but you will need to keep track of them in a database most probably, alternatively you could use a signed token in the link with an expiration time + filename and validate it upon reception.

D4no0

D4no0

Why not? I would generally encourage to go with the local storage by default and only switch to s3 only if you need specific features it offers, like for example navigating over the files from their interface or having automatic backups.

The performance is obviously better as you are not doing network calls, but you will have to figure out how to backup your files(if you need it) and this can vary extremely depending on how you deploy your application.

Last Post!

Liam_or

Liam_or

Thanks for the info guys. Really appreciate it!

Where Next?

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2976 91332 914
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
zachdaniel
Introducing AshStorage! Attachment and file management that slots directly into your resources :smiling_face_with_sunglasses: I had hope...
New

We're in Beta

About us Mission Statement