2012-04-27 111 views

回答

8

亞馬遜實際上provides one。在使用它的網絡上有很多例子。 Google是你的朋友。

6

亞馬遜有PHPSDK,檢查樣本代碼

// The sample code below demonstrates how Resource APIs work 


$aws = new Aws($config); 

// Get references to resource objects 



$bucket = $aws->s3->bucket('my-bucket'); 

$object = $bucket->object('image/bird.jpg'); 

// Access resource attributes 


echo $object['LastModified']; 

// Call resource methods to take action 


$object->delete(); 

$bucket->delete(); 

或者使用舊s3.php文件上傳到S3桶。它的一個單一的PHP文件名爲s3.php 你只需從你的代碼下載。更多閱讀this

<?php 


if (!class_exists('S3'))require_once('S3.php'); 
//AWS access info 
if (!defined('awsAccessKey')) define('awsAccessKey', 'YourAccess S3 Key'); 
if (!defined('awsSecretKey')) define('awsSecretKey', 'Yor Secret Key'); 
//instantiate the class 
$s3 = new S3(awsAccessKey, awsSecretKey); 
$s3->putBucket("bucket name", S3::ACL_PRIVATE); 

//move the file 
if ($s3->putObjectFile("your file name in the server with path", "which bucket ur using (bucket name)", "fine name in s3 server", S3::ACL_PRIVATE)) { 

//s3 upload success 

} 
?> 
+0

此課程不是來自亞馬遜。這是第三方課程。 – 2013-07-07 16:24:26

+1

我一直在尋找S3.php(是的,第三方類),主要是因爲它比Amazon的PHP SDK更小更簡單。最後在這裏找到它:https://raw.githubusercontent.com/tpyo/amazon-s3-php-class/master/S3.php – YudhiWidyatama 2016-08-15 06:53:16