2012-09-12 134 views
1

我成功地使用下面的代碼將文件寫入到S3:S3.php - 將文件寫入到Amazon 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腳本更新這個'圖像/ JPEG'?例如:是否有一個屬性可以添加到上面的代碼或額外的行?

THX

回答

0

您可以通過內容類型作爲這樣的字符串:

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