This is a migrated thread and some comments may be shown as answers.

Cordova Read/Write binary file

3 Answers 92 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gary
Top achievements
Rank 1
Gary asked on 18 Oct 2016, 11:37 PM

I found the requestFileSystem to read and write to a text file which works fine for text ... is there an API to read and write a binary file?

In my app, I want to download a file from a server, and write it to storage inside my app.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 21 Oct 2016, 10:03 AM
Hi,

This functionality can be incorporated in your app using the File Transfer plugin which you can see in action here. It allows for downloading a file from a remote resource and storing it on the device file system.

Let me know if this works for you.

Regards,
Anton Dobrev
Telerik by Progress
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Jay
Top achievements
Rank 1
answered on 21 Oct 2016, 05:50 PM

That works great, thx.

For a related question, how can I launch that downloaded file (e.g. DOCX, PPTX, PDF, etc) using the associated application on the device? PDFs and images can probably simply be opened with window.open .... but what about other file types? Is there a way to launch them and just have whatever app is associated with the file type take over?

Thanks!

0
Anton Dobrev
Telerik team
answered on 26 Oct 2016, 12:39 PM
When the file is located on the device you can open it in several ways, using the local URI:

- in a object or anchor element with the respective URI as a source (for both platforms this should trigger the suggestion for an app that supports the flie type)
- using the InAppBrowser
- using a custom plugin (this is Android only - https://www.npmjs.com/package/cordova-plugin-fileopener and I am not aware of such for iOS)

Let me know if this works for you.

Regards,
Anton Dobrev
Telerik by Progress
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
General Discussion
Asked by
Gary
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Jay
Top achievements
Rank 1
Share this question
or