duanliang5051 2015-09-30 19:24
浏览 44

从S3下载使用readfile - 在readfile之后继续缓冲

I have a pretty simple script to force downloads from S3.

$headers = $this->s3->getObjectHeaders(array('Bucket' => $bucket, 'Key' => $s3name));
    $headerArray = $headers->toArray();

    // force download in this case
    header("Content-disposition: attachment; filename=\"{$filename}\"");

    if (ob_get_level()) {
      ob_end_flush();
    }

    flush();

    readfile("s3://{$bucket}/{$s3name}"); 
    exit;
    return;

If I remove the "exit", the resulting downloaded file contains extra content at the end.

In the case of a JSON file, it adds {}.

If there was a bug AFTER readfile, the HTML error content of the bug is APPENDED to the downloaded file.

I can STOP this unwanted action by simply adding exit. BUT, this prevents me from doing any more processing at that point.

I've tried ob_end_flush(), etc, but to no avail.

Any ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探