download mp3 from web url with android failed

风流意气都作罢 提交于 2019-12-11 18:50:04

问题


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


回答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.



来源:https://stackoverflow.com/questions/10802789/download-mp3-from-web-url-with-android-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!