0

Here is my function to upload to S3 using PHP. I get this error:

The request signature we calculated does not match the signature you provided. Check your key and signing method.

I'm using the correct key and secret. What have i done wrong?

 function upload_s3bucket($file,$name,$bucket) {
        require(APPPATH.'/third_party/aws/aws-autoloader.php');
        $key = "*******";
        $secret = "************";
        $file = "/var/www/vhosts/example.com/website/assets/media/images/test.jpg";

        if(isset($file)){

            $s3 = new Aws\S3\S3Client([
                'region'  => 'us-east-1',
                'version' => 'latest',
                'credentials' => [
                    'key'    => $key,
                    'secret' => $secret,
                ]
            ]);     

            $result = $s3->putObject([
                'Bucket' => 'cdn-example.com/'.$bucket,
                'Key'    => $key,
                'SourceFile' => $file,
                'ACL'   => 'public-read'    
            ]);

            return $file_name;

        }

    }

Is the Object Key the same as Access Key? I'm using Access Key that i created from "Your Security Credentials".

1 Answer 1

1

No they are not the same the S3 Object key refers to a folder in an S3 bucket i.e s3://mybucket/mykey

The credential key is your access key and secret key.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.