我有一个网站托管在亚马逊上。我希望我的客户能够将他们的亚马逊s3空间中已经存在的文件上传到我的s3空间。有没有支持这个功能的php API?
发布于 2012-04-27 11:56:11
亚马逊实际上是provides one。在网络上有很多使用它的例子。谷歌是你的朋友。
发布于 2012-04-27 13:28:06
亚马逊有一个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存储桶。它只是一个名为s3.php的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
}
?>https://stackoverflow.com/questions/10344504
复制相似问题