尝试使用 s3 的 PHP SDK 上传文件。将文件上传到现有的Bucket,弹出错误。
<?php
error_reporting(-1);
// Set plain text headers
header("Content-type: text/plain; charset=utf-8");
// Include the SDK
require_once '../sdk.class.php';
// %** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * * %*/ // 上传文件到 S3
// Instantiate the AmazonS3 class
$s3 = new AmazonS3();
$s3->path_style = true;
$bucket = 'photossss1.abc.com';
$name = "picture.jpg" ;
$response = $s3->create_object($bucket, 'picture2.jpg', array(
'fileUpload' => 'picture.jpg'
));
if($response->isOk()){
echo " Done" ;
} else {
//var_dump($response);
echo "error: create_object error.";
}
上面的代码有什么错误..?
调试: print_r($response->body); =>
CFSimpleXML Object
(
[Code] => PermanentRedirect
[Message] => The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
[RequestId] => DACD5C54BC4BD82
[Bucket] => photossss1.abc.com
[HostId] => QUBlZEZKh0Ujzk6UyGG7LjC0vMCWDlOPszTZru/+OpWidBH84VXor1
[Endpoint] => photossss1.abc.com.s3.amazonaws.com
)