greenz1

greenz1

I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending multiple files. I have tried send_file/5 but it can only send single files at a time.

Should I make these downloads independent or send all the files in bulk? Downloading in bulk helps me reduce the number of HTTP requests.

Showing Posts 1 to 3

sarat1669

sarat1669

I don’t think you can send multiple files over a HTTP request. One option would be to add them to a zip.

hubertlepicki

hubertlepicki

So that’s not precisely true, I mean it’s precise historically speaking but you have slightly more options nowadays with modern browsers. I’m not saying it’s good or easy options but there are.

One option would be to download the files to the browser’s memory with say JavaScript fetch API Using the Fetch API - Web APIs | MDN . Once you have the file in memory you can then save the file to the filesystem with file system JavaScript API (example: https://jsfiddle.net/koldev/cW7W5/).

One could approach this by concatenating the files server side, with some boundary marker in between, then download the files to browser memory, split it by boundary marker into multiple Blobs, then for each Blob trigger saving to filesystem.

I think at this point browsers (at least Chrome) would actually warn user that “this web site is trying to download multiple files” within a top bar pop up but user can still allow it.

Overall, I do not think it’s worth it. Just do multiple HTTP calls from web site to the back-end, or use ZIP to package multiple files into one.

greenz1

greenz1 OP

Thanks @hubertlepicki and @sarat1669

I think it won’t hurt getting all the images one at a time. JS’ Fetch API requires me to exercise extra caution. and might lead to bizarre errors.

I will go with multiple HTTP calls

— 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
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
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
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