2

Using fine-uploader and the following php s3 endpoint template file:

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

The image uploads successfully on the s3 bucket but i cannot get any response back (for example to get the tempLink) in my:

}).on('complete', function(event, id, name, response) {
    console.dir(response);
});

I get the following fatal error:

[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. 

Which points to this file in the 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;
}
odd_duck
  • 3,941
  • 7
  • 43
  • 85
  • Which specific server side request is failing, and what parameters are being sent with that request? – Ray Nicholus May 17 '14 at 14:48
  • @RayNicholus i am not sure which specific server side request is failing, how can i check? The parameters i am passing are just retry and validation (allowedExtensions, and sizeLimit) – odd_duck May 17 '14 at 15:11
  • You'll need to add appropriately placed log statements to figure out exactly where this is failing, or some similar debugging technique. – Ray Nicholus May 17 '14 at 15:27
  • @RayNicholus Seems like this could be a similar issue where they had to set the region correctly. Is there anywhere in fine uploader where i can specify the endpoint of my bucket region – odd_duck May 17 '14 at 15:50
  • @RayNicholus apologies forgot the link: http://stackoverflow.com/questions/13691881/301-moved-permanently-after-s3-uploading#13703595 – odd_duck May 17 '14 at 16:01
  • You should specify the bucket endpoint via the request.endpoint option. The bucket URL should contain the region specific identifier, if appropriate. – Ray Nicholus May 17 '14 at 16:37
  • 1
    @RayNicholus - got this working at last with the answer below. It was the missing region property. Thanks for your help throughout though, appreciated – odd_duck May 17 '14 at 19:24

1 Answers1

2

Finally got this working. The issue was i was missing the region property when instantiating the client object in `getS3Client() as below

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

    return S3Client::factory(array(
        'key' => $serverPublicKey,
        'secret' => $serverPrivateKey,
        'region' => 'xx-xxxx-x'
    ));
}
odd_duck
  • 3,941
  • 7
  • 43
  • 85