Save file when using ionic serve


#1

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.


#2

No.

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


#3

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.


#4

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

Do you have lots?


#5

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.


#6

Another possibility is to connect to a local database.


#7

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.


#8

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.


#9

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


#10

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.