使用fine-uploader和以下php s3端点模板文件:
图片成功上传到s3存储桶,但我无法在我的页面中得到任何响应(例如获取tempLink):
}).on('complete', function(event, id, name, response) {
console.dir(response);
});我得到以下致命错误:
[Fine Uploader 4.4.0] Submitting upload success request/notification for 0
[Fine Uploader 4.4.0] Sending POST request for 0
[Fine Uploader 4.4.0] Received the following response body to an upload success request for id 0: <br />
<b>Fatal error</b>: Uncaught Aws\S3\Exception\S3Exception: AWS Error Code: , Status Code: 301, AWS Request ID: 7103DD45F997003C, AWS Error Type: client, AWS Error Message: 301 Moved Permanently (Request-ID: 7103DD45F997003C), User-Agent: aws-sdk-php2/2.6.3 Guzzle/3.9.1 curl/7.24.0 PHP/5.3.28
thrown in <b>/xxxxx/aws/Aws/Common/Exception/NamespaceExceptionFactory.php</b> on line <b>91</b><br />
[Fine Uploader 4.4.0] Upload success was acknowledged by the server. 它指向php aws sdk中的这个文件:
aws/Aws/Common/Exception/NamespaceExceptionFactory.php
/**
* Create an prepare an exception object
*
* @param string $className Name of the class to create
* @param RequestInterface $request Request
* @param Response $response Response received
* @param array $parts Parsed exception data
*
* @return \Exception
*/
protected function createException($className, RequestInterface $request, Response $response, array $parts)
{
$class = new $className($parts['message']);
if ($class instanceof ServiceResponseException) {
$class->setExceptionCode($parts['code']);
$class->setExceptionType($parts['type']);
$class->setResponse($response);
$class->setRequest($request);
$class->setRequestId($parts['request_id']);
}
return $class;
}发布于 2014-05-18 03:23:05
终于让它起作用了。问题是在`getS3Client()中实例化client对象时缺少region属性,如下所示
function getS3Client() {
global $serverPublicKey, $serverPrivateKey;
return S3Client::factory(array(
'key' => $serverPublicKey,
'secret' => $serverPrivateKey,
'region' => 'xx-xxxx-x'
));
}https://stackoverflow.com/questions/23712357
复制相似问题