Download a dir

i would post some code but nothing i have had works i have user filetransfer combined with unzip along with the actual downloader looking to see if anyone has had any success downloading a directory zipped or unzipped and how you accomplished it. Any help or guidance would be appreciated.

Forget completely about filetransfer. It’s been obsolete for years. Use Angular’s HttpClient instead. As for “downloading a directory”, that’s outside of the scope of HTTP, so you would have to create a REST endpoint server-side that, when asked for whatever identifies “a directory” in your mind and delivers something as a response that your client-side app will be happy with.

In other words, this goes beyond something you can do completely within the Ionic app.

1 Like

ok so if i make a http.get request and get the object from the api. how would i at that point put it on the phone storage using capacitor filesystem? would i have to convert a mp4 file to a string value and then write the file or is there another method to save it to the device that i am not aware of. I am attempting to avoid the user deciding where the files go since this is a learning app made for schools in which it will be pulling json manifests. this app is going on chromebooks where there only function is to run this app. so im just trying to find out how to go about doing the file saving on a device after the request is made

My first instinct would be to get this functionality out of the Ionic app, because you’re effectively looking at reinventing a fairly large and complex wheel. How about something like Ansible, which I believe runs on Chromebooks?

If, however, you’re committed to trying to do it in Ionic, and you are dealing with lots of heavy assets, Capacitor has a bit of a rather troubling (IMHO) limitation that you mentioned: everything going across the JavaScript / native bridge has to be a printable string, which has some rather undesirable consequences for performance. This may be premature optimization, since one doesn’t typically download lesson plans so frequently, but you could look at diachedelic/capacitor-blob-writer, which uses an embedded httpd to bypass this limitation.

1 Like