0

I have a link to download mp3 on all mobile device they can read them. I also have an Acer E320 with Android 2.3.4 and I want to download my mp3 by clicking my link (web server Apache; this is some PHP source behind that link).

I tried with a BlackBerry, and I got the file. I tried with my Firefox browser with a user-agent of a Samsung Galaxy S with Android, and I got the file. I tried with my Acer E320 with the same Android 2.3.4, and... I didn't get the file.

I am obviously sure that comes from the OS, I'll try with a Windows Phone tomorrow but I'm pretty sure this will works.

Here are my sources for the download:

    <?php
    // assume that all variables are correctly set
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control:");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type: audio/mpeg");
    header('Content-Disposition: attachment; filename="'.$filename.'";');
    header("Content-Transfer-Encoding: binary");
    header('Content-Range: ' . $download_range);
    header('Content-Length: ' . $download_size);
    readfile($filename);
    ?>

Thank you if you have any idea why this code doesn't work on an Android phone.

EDIT: I tried with an HTC with Windows Phone OS. The download didn't start but I can see my hit on the apache log... It seemes that Android is not alone...

2nd EDIT: I finnaly find it: there's a pre-fetch done with Android that kill my download because of a one-use token. Thanks all

niconoe
  • 1,191
  • 1
  • 11
  • 25
  • Did you confirm that the E320 actually transferred the full bytes, or even hit the server at all? (check the access log). – Marc B May 29 '12 at 16:20
  • @MarcB I just look at the access log and yes, I can see my hit on 1 of my 3 servers (I'm load-balanced). I also checked that $download_range == $download_size == filesize($filename). I finally confirm that $filename is an absolute path... – niconoe May 30 '12 at 08:07
  • please enter the answer below, and confirm it as best to help future users – Rene Pot Jun 04 '12 at 09:04

1 Answers1

1

I finally found it:

There's a pre-fetch done with Android that kills my download, because of a one-use token.

Thanks all.

Affe
  • 47,174
  • 11
  • 83
  • 83
niconoe
  • 1,191
  • 1
  • 11
  • 25