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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews