1

I am new to AWS. As I understand, S3 transfer acceleration uses the Cloudfront edges for fastest uploading, but I can't find the proper documentation for PHP API, for uploading object into transfer acceleration enabled bucket. My code :

use Aws\S3\S3Client;

 $S3_Client = new S3Client([
'version'     => 'latest',
'region'    =>'ap-south-1',
  'credentials' => [
        'key'    => 'Accesskey',
        'secret' => 'Secretkey',
  ],
 'endpoint' => 'http://my_bucket_name.s3-accelerate.amazonaws.com'
]);

$bucket = 'my_bucket_name';
$key = 'EC2.pdf';
$SourceFile = '/path/to/the/file/EC2.pdf';


$put = $S3_Client->putObject([
    'Bucket' => $bucket,
    'Key' => $key,
    'SourceFile' => $SourceFile
]);

I am getting the following error

The authorization header is malformed;
the region 'ap-south-1' is wrong; expecting 'us-east-1'

but my bucket is located in us-east-1 , when I change the region as

us-east-1

I am getting the following error:

The specified bucket does not exist
2
  • Instead of endpoint => ..., please try 'use_accelerate_endpoint' => True in the client constructor and see what that does. You will also need to set the region to the bucket's region, since that is used for authentication. Commented Mar 12, 2018 at 11:30
  • Yes its working ... ! But, what is the use of endpoint @Michael-sqlbot Commented Mar 12, 2018 at 11:38

2 Answers 2

6

Instead of endpoint => ..., pass 'use_accelerate_endpoint' => True to the constructor.

There are a number of different rules that come into play when building a request to send to S3. The endpoint option provides a service endpoint, rather than a bucket endpoint, and is mostly useful for non-standard configurations.

Sign up to request clarification or add additional context in comments.

2 Comments

when enable transfer acceleration to a bucket , the endpoint appears ... what is the use of that .. they are not used in accelerate a speed ?
@ArunKumar you are referring to the endpoint that appears in the console? Yes, that is the endpoint used for acceleration, but if you are using one of the SDKs, that isn't information that you need, because enabling acceleration in the SDK generates the correct endpoint automatically. It is always https://${bucket}.s3-accelerate.amazonaws.com (or, newly-introduced, https://${bucket}.s3-accelerate.dualstack.amazonaws.com for IPv6) so the SDKs can calculate the endpoint automatically using only the bucket name.
0

This may be related to this discussion: https://github.com/hashicorp/terraform/issues/2774

Try the following solution - "I had same issue, i had created the bucket previously and deleted it. I changed the name and it applied no problem."

3 Comments

I changed the bucket and enable transfer acceleration , Its not working for above code
Sorry, though it was the region bug problem.
Found github.com/aws/aws-sdk-php/issues/1372 AND github.com/aws/aws-sdk-php/blob/master/src/S3/S3Client.php#L196. Apparently you can just add use_accelerate_endpoint => true to the settings and remove the endpoint setting. Then your queries will be automatically routed to the accelerator endpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.