PHP强制下载AmazonS3链接


PHP force download of Amazon S3 link

我有以下代码

        header("Content-Description: File Transfer");
        header('Content-Type: audio/mp3');
        header("Content-Disposition: attachment; filename=" . $arrResults['audioLink'] . ".mp3");
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header("Content-Transfer-Encoding: binary");
        $strLink = 'http://ag-org.s3.amazonaws.com/members/tele_classes/' . $arrResults['audioLink'];
        ob_clean();
        flush();
        readfile($strLink);

但是,当单击执行此代码的下载链接时,它总是返回一个0字节的文件。bucket中的所有文件都设置为public。

我在这里做错了什么?

.mp3扩展名真的不是文件名的一部分吗,因为它存储在S3上?

您将.mp3附加到Content-Disposition标头中的文件名,而不是传递给readfile的URL。