Cordova download file from location
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Cordova - Download a file in download folder Ask Question. Asked 4 years, 7 months ago. Active 4 years, 7 months ago. Viewed 29k times. Improve this question. Zappescu Zappescu 1, 2 2 gold badges 10 10 silver badges 24 24 bronze badges.
Add a comment. Active Oldest Votes. Improve this answer. L Balsdon L Balsdon 8 8 silver badges 12 12 bronze badges. Ok I used the readBinaryFile explained in the official plugin doc github. Sign in to your account. Great plugin,what i don't understand is where to put the database file and be able to read it in my app for both testing and normal usage on devices.
The text was updated successfully, but these errors were encountered:. I am not sure if I really understand your question. When the app calls sqlitePlugin. For each platform, the database file should be in the same path relative to your app regardless whether you are running it on an emulator or on a real device. There is a createFromLocation option that copies the database file from the app's www directory if it is not already present pre-populated database , documented in README.
Sorry, something went wrong. Just in case that the App needs to download the sqlite DB from internet and save it in the device below the summary of the locations quick and dirty, but I guess its readable :. Hi, I will try to clarify my question,i did create a database using an sqlite tool,i have the database file ready to use,i just need to know where to save it in my cordova app project,and should i use createFromLocation in this case?
MohamedMehrez : the createFromLocation option is the supported way to use the pre-populated database that you create using the sqlite tool, as described in the readme. If you don't see your data from the sqlite tool, please remove your app from the emulator or device and try it again. Thanks jlegido for your input!
The DB location will be documented in the readme. Thank you so much guys,i'm getting used to it now,the only problem is that i get a bunch of errors and i'm trying to fix it,have anyone experienced any problems when using angularjs with this plugin? Some people have raised questions in the past about using the plugin with Ionic which is built on AngularJS.
Just to add a comment , I have experienced the problem with the DB not copying a pre-polulated one but dropping to a certain version of the plugin fixed the issues as below ;. Its an awesome plugin though brodybits legend. When you have the FileEntry object, download the file using the download method of the FileTransfer object. The 3rd argument to the download function of FileTransfer is the success callback, which you can use to call the app's readBinaryFile function.
In this code example, the entry variable is a new FileEntry object that receives the result of the download operation. Depending on your app requirements, you may want to read the file. Once you read the file successfully, construct a Blob object using the result of the read. As you saw previously, you can call FileEntry. When you upload a File using the File-Transfer plugin, use the File plugin to provide files for upload again, they must be FileEntry objects.
Before you can upload anything, create a file for upload using the getFile method of DirectoryEntry. In this example, create the file in the application's cache fs.
Then call the app's writeFile function so you have some content to upload. Forward the FileEntry object to the upload function. To perform the actual upload, use the upload function of the FileTransfer object.
Again, the success handler for the FileTransfer.