joshua-bouv

joshua-bouv

This is probably a very silly question, but I’m still interested in the answer nonetheless! I’m also fairly novice so apologies for any outrageously silly assumptions I might of made!

Part of my application requires allowing authenticated users to download files uploaded by other authenticated users (around 1-10mb each).

The frequency (kinda guessing here) could be once every several minutes to a maximum of a few simultaneously, and each download will likely be serving a different file. The download speed doesn’t really matter.

Is creating an application to handle this in elixir/using phoenix a very silly idea and I should use some other language/framework or would it be fine?

I would likely have the files stored on a separate server with a very high bandwidth cap and lots of storage space, which I guess would also house the application that handles incoming download requests.

I’d then hopefully have cloudflare route a web request either to my web servers or download server to prevent my transfer caps getting obliterated on the web servers. (I’m hoping this is a thing I can do, never really used cloudflare before!)

Thanks in advance!

Showing Posts 1 to 4

victorbjorklund

victorbjorklund

Don’t see why this wouldn’t be possible. I personally probably would just upload and download from an object storage (like Linode or Digital Ocean). That way uploads and downloads should be faster (since they can probably scale easier). And usually the bandwidth and storage cost is lower than if you store it directly on a server.

You can then use Phoenix to generate the time-limited token to upload directly to the object storage and if only certain users / only logged in users you can generate a token to download the file too. If it’s less sensitive you can put a CDN infront of it like Cloudflare to make it even faster/cheaper (technically you can’t use cloudflare only for files like that but unless you are doing many TB per day they probably won’t care).

dimitarvp

dimitarvp

As an education project – sure. But I see no reason why you wouldn’t just put the files somewhere and put the Caddy server software in front of them.

Or, as @victorbjorklund says, use various cloud providers for absolutely free unless somebody makes it a point to go download them 24/7 just so you can accumulate a cloud bill. :003: Which is extremely unlikely.

dmitriid

dmitriid

I’m doing this for a low traffic personal library (me and my mum :slight_smile: )

The download controller does basic auth to see if the user has the right to download the file, and then sends the file.

Something along the lines of

# for path /file/:id
# see if user is in session and/or authenticated, this can be done on plug level
# then find if the file exists and the user has access to it
# then 

        conn
        |> put_resp_content_type(... your content type ...)
        |> put_resp_header(
          "content-disposition",
          "attachment; filename=#{whatever filename you come up with}"
        )
        |> send_file(200, file)

I don’t see why this wouldn’t work even for significantly more users than a few at a time.

EDIT: Of course, if this becomes a problem, then other solutions like having them stored under one-time keys in an object storage as described above etc. would work better

joshua-bouv

joshua-bouv OP

Thank you to everyone who responded :heart:

I’ve never heard of object spaces before so thanks for opening my eyes! Will do some more digging and may end up going that route, whatever is the cheapest I guess!

Will start off by giving it a go in elixir though and see how that works out for me and also for the sake of learning something new!

Thanks again!

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
mnkhod
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews