I am trying to download file from amazon s3 but getting errorImporting product listings from Amazon into MagentoExport products from Amazon onto Magento?Error on Pay with Amazon ExtensionInstall Magento on Amazon EC2 ( Error The requested URL /magento/ was not found on this server)Amazon payment method checkout errorMagento 2 from Bitnami on Amazon Lightsail VPS servers won't upgrade and requires reindexing all the timeMagento 2 : Create Order from admin results in email error?How do I add a Buy from Amazon button in Magento2?Magento 2 - Amazon Pay ErrorMagento 2 - Error the specified key does not exist on Amazon aws cdn

How did Jayne know when to shoot?

Parser for STL stereolithography data files

Are there foods that astronauts are explicitly never allowed to eat?

How was Luke's prosthetic hand in Episode V filmed?

To what extent does asymmetric cryptography secure bitcoin transactions?

"This used to be my phone number"

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

I want light controlled by one switch, not two

What could make large expeditions ineffective for exploring territory full of dangers and valuable resources?

Tricky interview question for mid-level C++ developer

How do you name this compound using IUPAC system (including steps)?

You have no, but can try for yes

Align the contents of a numerical matrix when you have minus signs

Should I have shared a document with a former employee?

Discontinuous Tube visualization

Why teach C using scanf without talking about command line arguments?

Why is this guy handcuffed censored?

Why don't humans perceive sound waves as twice the frequency they are?

How slow ( not zero) can a car engine run without hurting engine and saving on fuel

I have found a mistake on someone's code published online: what is the protocol?

Should I have one hand on the throttle during engine ignition?

How should I interpret a promising preprint that was never published in a peer-reviewed journal?

Function over a list that depends on the index

Which family is it?



I am trying to download file from amazon s3 but getting error


Importing product listings from Amazon into MagentoExport products from Amazon onto Magento?Error on Pay with Amazon ExtensionInstall Magento on Amazon EC2 ( Error The requested URL /magento/ was not found on this server)Amazon payment method checkout errorMagento 2 from Bitnami on Amazon Lightsail VPS servers won't upgrade and requires reindexing all the timeMagento 2 : Create Order from admin results in email error?How do I add a Buy from Amazon button in Magento2?Magento 2 - Amazon Pay ErrorMagento 2 - Error the specified key does not exist on Amazon aws cdn






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to download file from amazon s3 but getting following error



<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>


Following code we use



<?php
$accessKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
$secretKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';

$datestamp = new DateTime( "now" );
$longdate = $datestamp->format( "Ymd\THisZ");
$shortdate = $datestamp->format( "Ymd" );
$date = date('Ymd',time());
$timestamp = date('Ymd',time()).'T'.date('His',time()).'Z';
$shortdate = date('Ymd',time());
$region = 'ap-south-1';
$service = 's3';
$request = 'aws4_request';
$ksecret = 'AWS4' . $secretKey;
$kdate = hash_hmac( 'sha256', $shortdate, $ksecret );
$kregion = hash_hmac( 'sha256', $region, $kdate );
$kservice = hash_hmac( 'sha256', $service, $kregion );
$ksigning = hash_hmac( 'sha256', $request, $kservice );
$canonicalRequest = "GETn";
$canonicalRequest .= "/n";
$canonicalRequest .= "n";
$canonicalRequest .= "host:bucketname.s3.amazonaws.comn";
$canonicalRequest .= "x-amz-date:". $timestamp ."n";
$canonicalRequest .= "n";
$canonicalRequest .= "host;x-amz-daten";
$canonicalRequest .= hash( 'sha256', '' );
$canonicalRequest = hash( 'sha256', $canonicalRequest );
$stringToSign = "AWS4-HMAC-SHA256n";
$stringToSign .= $longdate . "n";
$stringToSign .= $shortdate . "/". $region ."/". $service ."/". $request ."n";
$stringToSign .= $canonicalRequest;
echo $stringToSign;
echo "<br>";
echo $ksigning;
echo "<br>";
$signature = hash_hmac( 'sha256', $stringToSign, base64_encode($ksigning) );
$params = [
'X-Amz-Algorithm' => 'AWS4-HMAC-SHA256',
'X-Amz-Credential' => $accessKey . '/'. $shortdate .'/'. $region .'/'. $service .'/' . $request,
'X-Amz-Date' => $timestamp,
'X-Amz-Expires' => 86400,
'X-Amz-SignedHeaders' => 'host;x-amz-date',
'X-Amz-Signature' => trim($signature)
];
$url = 'https://bucketname.s3.amazonaws.com/1.jpg';
$count = 0;
foreach($params AS $key => $value)

$count++;
$url .= ($count == 1 ? '?' : '&') . $key .= '=' . $value;

echo $url . "
";









share|improve this question




























    0















    I am trying to download file from amazon s3 but getting following error



    <Code>SignatureDoesNotMatch</Code>
    <Message>
    The request signature we calculated does not match the signature you provided. Check your key and signing method.
    </Message>


    Following code we use



    <?php
    $accessKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
    $secretKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';

    $datestamp = new DateTime( "now" );
    $longdate = $datestamp->format( "Ymd\THisZ");
    $shortdate = $datestamp->format( "Ymd" );
    $date = date('Ymd',time());
    $timestamp = date('Ymd',time()).'T'.date('His',time()).'Z';
    $shortdate = date('Ymd',time());
    $region = 'ap-south-1';
    $service = 's3';
    $request = 'aws4_request';
    $ksecret = 'AWS4' . $secretKey;
    $kdate = hash_hmac( 'sha256', $shortdate, $ksecret );
    $kregion = hash_hmac( 'sha256', $region, $kdate );
    $kservice = hash_hmac( 'sha256', $service, $kregion );
    $ksigning = hash_hmac( 'sha256', $request, $kservice );
    $canonicalRequest = "GETn";
    $canonicalRequest .= "/n";
    $canonicalRequest .= "n";
    $canonicalRequest .= "host:bucketname.s3.amazonaws.comn";
    $canonicalRequest .= "x-amz-date:". $timestamp ."n";
    $canonicalRequest .= "n";
    $canonicalRequest .= "host;x-amz-daten";
    $canonicalRequest .= hash( 'sha256', '' );
    $canonicalRequest = hash( 'sha256', $canonicalRequest );
    $stringToSign = "AWS4-HMAC-SHA256n";
    $stringToSign .= $longdate . "n";
    $stringToSign .= $shortdate . "/". $region ."/". $service ."/". $request ."n";
    $stringToSign .= $canonicalRequest;
    echo $stringToSign;
    echo "<br>";
    echo $ksigning;
    echo "<br>";
    $signature = hash_hmac( 'sha256', $stringToSign, base64_encode($ksigning) );
    $params = [
    'X-Amz-Algorithm' => 'AWS4-HMAC-SHA256',
    'X-Amz-Credential' => $accessKey . '/'. $shortdate .'/'. $region .'/'. $service .'/' . $request,
    'X-Amz-Date' => $timestamp,
    'X-Amz-Expires' => 86400,
    'X-Amz-SignedHeaders' => 'host;x-amz-date',
    'X-Amz-Signature' => trim($signature)
    ];
    $url = 'https://bucketname.s3.amazonaws.com/1.jpg';
    $count = 0;
    foreach($params AS $key => $value)

    $count++;
    $url .= ($count == 1 ? '?' : '&') . $key .= '=' . $value;

    echo $url . "
    ";









    share|improve this question
























      0












      0








      0








      I am trying to download file from amazon s3 but getting following error



      <Code>SignatureDoesNotMatch</Code>
      <Message>
      The request signature we calculated does not match the signature you provided. Check your key and signing method.
      </Message>


      Following code we use



      <?php
      $accessKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
      $secretKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';

      $datestamp = new DateTime( "now" );
      $longdate = $datestamp->format( "Ymd\THisZ");
      $shortdate = $datestamp->format( "Ymd" );
      $date = date('Ymd',time());
      $timestamp = date('Ymd',time()).'T'.date('His',time()).'Z';
      $shortdate = date('Ymd',time());
      $region = 'ap-south-1';
      $service = 's3';
      $request = 'aws4_request';
      $ksecret = 'AWS4' . $secretKey;
      $kdate = hash_hmac( 'sha256', $shortdate, $ksecret );
      $kregion = hash_hmac( 'sha256', $region, $kdate );
      $kservice = hash_hmac( 'sha256', $service, $kregion );
      $ksigning = hash_hmac( 'sha256', $request, $kservice );
      $canonicalRequest = "GETn";
      $canonicalRequest .= "/n";
      $canonicalRequest .= "n";
      $canonicalRequest .= "host:bucketname.s3.amazonaws.comn";
      $canonicalRequest .= "x-amz-date:". $timestamp ."n";
      $canonicalRequest .= "n";
      $canonicalRequest .= "host;x-amz-daten";
      $canonicalRequest .= hash( 'sha256', '' );
      $canonicalRequest = hash( 'sha256', $canonicalRequest );
      $stringToSign = "AWS4-HMAC-SHA256n";
      $stringToSign .= $longdate . "n";
      $stringToSign .= $shortdate . "/". $region ."/". $service ."/". $request ."n";
      $stringToSign .= $canonicalRequest;
      echo $stringToSign;
      echo "<br>";
      echo $ksigning;
      echo "<br>";
      $signature = hash_hmac( 'sha256', $stringToSign, base64_encode($ksigning) );
      $params = [
      'X-Amz-Algorithm' => 'AWS4-HMAC-SHA256',
      'X-Amz-Credential' => $accessKey . '/'. $shortdate .'/'. $region .'/'. $service .'/' . $request,
      'X-Amz-Date' => $timestamp,
      'X-Amz-Expires' => 86400,
      'X-Amz-SignedHeaders' => 'host;x-amz-date',
      'X-Amz-Signature' => trim($signature)
      ];
      $url = 'https://bucketname.s3.amazonaws.com/1.jpg';
      $count = 0;
      foreach($params AS $key => $value)

      $count++;
      $url .= ($count == 1 ? '?' : '&') . $key .= '=' . $value;

      echo $url . "
      ";









      share|improve this question














      I am trying to download file from amazon s3 but getting following error



      <Code>SignatureDoesNotMatch</Code>
      <Message>
      The request signature we calculated does not match the signature you provided. Check your key and signing method.
      </Message>


      Following code we use



      <?php
      $accessKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
      $secretKey = 'xxxxxxxxxxxxxxxxxxxxxxxxx';

      $datestamp = new DateTime( "now" );
      $longdate = $datestamp->format( "Ymd\THisZ");
      $shortdate = $datestamp->format( "Ymd" );
      $date = date('Ymd',time());
      $timestamp = date('Ymd',time()).'T'.date('His',time()).'Z';
      $shortdate = date('Ymd',time());
      $region = 'ap-south-1';
      $service = 's3';
      $request = 'aws4_request';
      $ksecret = 'AWS4' . $secretKey;
      $kdate = hash_hmac( 'sha256', $shortdate, $ksecret );
      $kregion = hash_hmac( 'sha256', $region, $kdate );
      $kservice = hash_hmac( 'sha256', $service, $kregion );
      $ksigning = hash_hmac( 'sha256', $request, $kservice );
      $canonicalRequest = "GETn";
      $canonicalRequest .= "/n";
      $canonicalRequest .= "n";
      $canonicalRequest .= "host:bucketname.s3.amazonaws.comn";
      $canonicalRequest .= "x-amz-date:". $timestamp ."n";
      $canonicalRequest .= "n";
      $canonicalRequest .= "host;x-amz-daten";
      $canonicalRequest .= hash( 'sha256', '' );
      $canonicalRequest = hash( 'sha256', $canonicalRequest );
      $stringToSign = "AWS4-HMAC-SHA256n";
      $stringToSign .= $longdate . "n";
      $stringToSign .= $shortdate . "/". $region ."/". $service ."/". $request ."n";
      $stringToSign .= $canonicalRequest;
      echo $stringToSign;
      echo "<br>";
      echo $ksigning;
      echo "<br>";
      $signature = hash_hmac( 'sha256', $stringToSign, base64_encode($ksigning) );
      $params = [
      'X-Amz-Algorithm' => 'AWS4-HMAC-SHA256',
      'X-Amz-Credential' => $accessKey . '/'. $shortdate .'/'. $region .'/'. $service .'/' . $request,
      'X-Amz-Date' => $timestamp,
      'X-Amz-Expires' => 86400,
      'X-Amz-SignedHeaders' => 'host;x-amz-date',
      'X-Amz-Signature' => trim($signature)
      ];
      $url = 'https://bucketname.s3.amazonaws.com/1.jpg';
      $count = 0;
      foreach($params AS $key => $value)

      $count++;
      $url .= ($count == 1 ? '?' : '&') . $key .= '=' . $value;

      echo $url . "
      ";






      aws amazon-web-services amazon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 11 at 11:15









      Chirag GondaliyaChirag Gondaliya

      969 bronze badges




      969 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          I try following way to solve this problem



          <?php
          require('aws.phar');

          use AwsS3S3Client;
          use AwsS3ExceptionS3Exception;

          $config = array(
          'version' => '2006-03-01',
          'credentials' => [
          'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
          'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
          ],
          'region' => 'ap-south-1', // your region get from amazon s3
          );

          $s3v2 = S3Client::factory($config);
          $cmd = $s3v2->getCommand('GetObject', [
          'Bucket' => 'bucket_name',
          'Key' => '1.jpg' // file name
          ]);

          $request = $s3v2->createPresignedRequest($cmd, '+20 minutes');

          // Get the actual presigned-url
          $presignedUrl = (string)$request->getUri();
          echo $presignedUrl;
          ?>





          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281725%2fi-am-trying-to-download-file-from-amazon-s3-but-getting-error%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I try following way to solve this problem



            <?php
            require('aws.phar');

            use AwsS3S3Client;
            use AwsS3ExceptionS3Exception;

            $config = array(
            'version' => '2006-03-01',
            'credentials' => [
            'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
            'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
            ],
            'region' => 'ap-south-1', // your region get from amazon s3
            );

            $s3v2 = S3Client::factory($config);
            $cmd = $s3v2->getCommand('GetObject', [
            'Bucket' => 'bucket_name',
            'Key' => '1.jpg' // file name
            ]);

            $request = $s3v2->createPresignedRequest($cmd, '+20 minutes');

            // Get the actual presigned-url
            $presignedUrl = (string)$request->getUri();
            echo $presignedUrl;
            ?>





            share|improve this answer



























              0














              I try following way to solve this problem



              <?php
              require('aws.phar');

              use AwsS3S3Client;
              use AwsS3ExceptionS3Exception;

              $config = array(
              'version' => '2006-03-01',
              'credentials' => [
              'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
              'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
              ],
              'region' => 'ap-south-1', // your region get from amazon s3
              );

              $s3v2 = S3Client::factory($config);
              $cmd = $s3v2->getCommand('GetObject', [
              'Bucket' => 'bucket_name',
              'Key' => '1.jpg' // file name
              ]);

              $request = $s3v2->createPresignedRequest($cmd, '+20 minutes');

              // Get the actual presigned-url
              $presignedUrl = (string)$request->getUri();
              echo $presignedUrl;
              ?>





              share|improve this answer

























                0












                0








                0







                I try following way to solve this problem



                <?php
                require('aws.phar');

                use AwsS3S3Client;
                use AwsS3ExceptionS3Exception;

                $config = array(
                'version' => '2006-03-01',
                'credentials' => [
                'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
                'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
                ],
                'region' => 'ap-south-1', // your region get from amazon s3
                );

                $s3v2 = S3Client::factory($config);
                $cmd = $s3v2->getCommand('GetObject', [
                'Bucket' => 'bucket_name',
                'Key' => '1.jpg' // file name
                ]);

                $request = $s3v2->createPresignedRequest($cmd, '+20 minutes');

                // Get the actual presigned-url
                $presignedUrl = (string)$request->getUri();
                echo $presignedUrl;
                ?>





                share|improve this answer













                I try following way to solve this problem



                <?php
                require('aws.phar');

                use AwsS3S3Client;
                use AwsS3ExceptionS3Exception;

                $config = array(
                'version' => '2006-03-01',
                'credentials' => [
                'key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
                'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
                ],
                'region' => 'ap-south-1', // your region get from amazon s3
                );

                $s3v2 = S3Client::factory($config);
                $cmd = $s3v2->getCommand('GetObject', [
                'Bucket' => 'bucket_name',
                'Key' => '1.jpg' // file name
                ]);

                $request = $s3v2->createPresignedRequest($cmd, '+20 minutes');

                // Get the actual presigned-url
                $presignedUrl = (string)$request->getUri();
                echo $presignedUrl;
                ?>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 12 at 4:08









                Chirag GondaliyaChirag Gondaliya

                969 bronze badges




                969 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281725%2fi-am-trying-to-download-file-from-amazon-s3-but-getting-error%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form