Remote File Download?

  • 1
  • Question
  • Updated 9 years ago
How would I initiate a file download without the user being able to see the URL? If I just link to the remote file the URL is shown in the android browser window that is opened.
Photo of Kody Jon Peterson

Kody Jon Peterson

  • 6 Posts
  • 0 Reply Likes
  • really hoping to get a fix.

Posted 9 years ago

  • 1
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
You have two options I can think of off the top of my head:

One, is to write a plugin for android.

http://wiki.phonegap.com/w/page/36753...

The Second (for the truly brave) which I have not tested but should still work in theory is to request the file via xhr in base64 then convert it to binary and write it out using the file api in PhoneGap.

I honestly suggest the first option :)

Hardeep Shoker
Photo of Kody Jon Peterson

Kody Jon Peterson

  • 6 Posts
  • 0 Reply Likes
Well, I cant use a plugin since I am using phonegap build :/

Does that mean I have to go the truly brave route? :/
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Yes, so currently PhoneGap build does not include building with plugins.

What kind of file are you downloading? You may need to use the second approach if the data is binary, however if you are requesting text data then no conversion of bases is necessary and you may simply use the file api.

Hardeep Shoker
Photo of Kody Jon Peterson

Kody Jon Peterson

  • 6 Posts
  • 0 Reply Likes
I am trying to download an apk file. The user will click the link and than the apk will download.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Yes you will need to do some encoding then.

Hardeep Shoker
Photo of Kody Jon Peterson

Kody Jon Peterson

  • 6 Posts
  • 0 Reply Likes
Well now Im screwed. (hits head on desk)