Save file when using ionic serve

Is it possible to save data to a local file whilst running ionic serve?

I know there is ionic native file - but that uses cordova.


Best you could do is to save the data to local storage.

Thanks @Judgewest2000
I could run a local node server and make http calls to that server and use the node.js fs file system to save the file to disk. It just seems like going around the houses for something which should be straight forward.

Honestly - what’s wrong with just saving your data to local storage???

Do you have lots?

Unfortunately that’s the case and it is audio recording - I think it would exceed local storage very quickly (1500 files each file about 50k), plus the bigger problem is how to then transfer the data from the local storage.

I was hoping someone has already used the node.js fs system directly within Ionic.

Another possibility is to connect to a local database.

That’s 75mb. A lot of local storage sizes max out at 5mb or 10mb whether you do localstorage / indexedb / websql.

You might need a different strategy I’m sorry to say.

Why do you need to store 75MB on ionic serve? This is not a production webserver but a debugging and development tool. If you want to deploy your Ionic app as a PWA/web app, use a proper HTTP server. But yes, uploading huge amounts of files/data is not supported in web apps - this needs a backend.

You are right a proper server is the way to go.

Put those calls into a provider which can do one or the other (save to end point / save to file system) and have it react based on if it’s natively ran or not.

1 Like