Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
699 views
in Technique[技术] by (71.8m points)

javascript - Download file to downloads folder ios/android using phonegap

I am getting a JSON response from a web service that returns a file in either binary or base64 . I want to save this file to the fileSystem.

  1. I wanted to know the ideal (default/industry standard ) location to download these files for IOS/ ANdroid on the file system.
  2. IF there is no ideal place i would want to save them in the default downloads folder for IOS/Android. I would then like to know what is the location of these folders.

I also wanted to know which methods in the Phonegap FileAPi i need to use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is no default place for downloads

Look the phonegap's File API for more info.

With phonegap you can request de temporary or the permanent file system

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);

on iOS PERSISTENT returns the Documents directory, and the TEMPORARY returns the Caches directory on Android PERSISTENT returns the root of the SD card or phone memory, and TEMPORARY returns a folder inside the data folder.

To download the files use the FileTransfer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...