Fine Uploader - 301永久致命致命错误

时间:2014-05-17 14:18:49

标签: php amazon-s3 fatal-error fine-uploader

使用精细上传器和以下php s3端点模板文件:

https://github.com/Widen/fine-uploader-server/blob/master/php/s3/s3demo-thumbnails-cors.php#L241-L248

图片在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;
}

1 个答案:

答案 0 :(得分:2)

终于搞定了。问题是我在`getS3Client()中实例化客户端对象时错过了region属性,如下所示

function getS3Client() {
    global $serverPublicKey, $serverPrivateKey;

    return S3Client::factory(array(
        'key' => $serverPublicKey,
        'secret' => $serverPrivateKey,
        'region' => 'xx-xxxx-x'
    ));
}