无法加载图像解释jpeg文件时出错

时间:2019-07-10 09:57:09

标签: php amazon-s3

无法加载图像解释jpeg文件时出错

除jpeg / png以外的所有文件都在工作,这可能是个问题吗?

预先感谢

require 'vendor/autoload.php';

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

$bucket = '*** Your Bucket Name ***';
$keyname = '*** Your Object Key ***';

$s3 = new S3Client([
    'version' => 'latest',
    'region'  => 'us-east-1'
]);

try {
    // Get the object.
    $result = $s3->getObject([
        'Bucket' => $bucket,
        'Key'    => $keyname
    ]);

    // Display the object in the browser.

    header("Content-Type: {$result['ContentType']}");
    header('Content-Disposition: filename="' . basename( $key ) . '"');
    echo $result['Body'];
} catch (S3Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}

0 个答案:

没有答案