S3.将文件写入AmazonS3


S3.writing files to Amazon S3

我成功地使用以下代码将文件写入S3:

<?php
        require_once 'S3.php';
        // Instantiate the class
        $s3 = new S3('AKIAJNIMGH2SZ5YRGTTA', 'dpIf3P7YsW38IosMTzX30KkMfTE7zkX77wuuIRzk', true, 's3-ap-southeast-1.amazonaws.com');
        // dirname(__FILE__).'/S3.php' - this is the full server path to the file
        $s3->putObjectFile(dirname(__FILE__).'/S3.php', 'dating-images.goneglobal.com', '1000089762/new-file-user.jpg', S3::ACL_PUBLIC_READ);
?>

我注意到元数据默认为"text/plain"。如何通过php脚本将其更新为"image/jpeg"?有没有一个属性我可以添加到上面的代码或额外的一行?

thx

您可以通过以下方式将内容类型作为字符串传递:

$s3->putObjectFile(dirname(__FILE__).'/S3.php', 'dating-images.goneglobal.com', '1000089762/new-file-user.jpg', S3::ACL_PUBLIC_READ, array(), 'image/jpeg');