0

我正在尝试通过我的 EC2 微型实例(使用 undesign.org.za S3 PHP 类)下载 Amazon S3 私有对象。这是我的脚本。实际上脚本正在运行,但有时需要几秒钟才能开始下载。我对我使用的标题并不十分信任。所有建议都非常感谢。

我的 S3 存储桶和 EC2 实例(目前是它的微型实例)在同一区域。

if (!class_exists('S3')) require_once '../include/S3.php';
$s3 = new S3("XXXXXXXXXXXXXX", "xxxxxxxxxxxxxx");

    $fileX=filename.mp3;// File Name
    $bucket='mybucket';
    $uri="username/public/filename.mp3"; // File path inside bucket

    //undesigned.org.za S3 PHP Class

    $info = $s3->getObjectInfo($bucket, $uri);
    $file = S3::getAuthenticatedURL($bucket, $uri, 3600);

    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."\"$fileX\"");
    header('Content-Transfer-Encoding: binary');
    header('Cache-Control: max-age=28800');
    header('Expires:' . gmdate('D, d M Y H:i:s T', strtotime('+8 hours')));
    header('Content-Length: '.$info[size]);
    ob_clean();
    flush();
    readfile($file);

我的问题是,

  1. 为什么我的响应时间很长?
  2. 我使用了正确的标题吗?
  3. 执行此操作的最佳 S3 PHP 类是什么?
4

0 回答 0