Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 Forbidden response #16

Open
supritha99games opened this issue Jan 19, 2021 · 1 comment
Open

403 Forbidden response #16

supritha99games opened this issue Jan 19, 2021 · 1 comment

Comments

@supritha99games
Copy link

Getting this 403 Forbidden response for the code -
Trying to upload an image file to Akamai storage.

` $signer = new \Akamai\NetStorage\Authentication();
$signer->setKey($key, $keyName);

        $handler = new \Akamai\NetStorage\Handler\Authentication();
        $handler->setSigner($signer);

        $stack = \GuzzleHttp\HandlerStack::create();
        $stack->push($handler, 'netstorage-handler');

        $client = new \Akamai\Open\EdgeGrid\Client([
            'base_uri' => $host,
            'handler' => $stack,
        ]);

        $client->put('/' . $cpCode . '/Test', [
            'headers' => [
                'X-Akamai-ACS-Action' => 'version=1&action=upload&sha1=' .sha1($img)
            ],
            'body' => $img
        ]);`

Variable '$img' is the base64 decoded string of the image.
'/Test' is the directory inside Akamai.

Error - "e":"Client error: PUT https://hostname/cpcode/Test resulted in a 403 Forbidden response","file":"/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php","line":113,"code":403

Formatted Output

Wanted few clarifications on usage of the above library -

  1. How to go about 403 Forbidden response?
  2. Where to mention the name of the image to be uploaded?
  3. How to give the image file path that exists on some other server to be uploaded to Akamai? (Instead of giving the file content)
@francescjimenez
Copy link

I think this should solve your issue: #17

The function that is signing the request is wrong. I solved it, and now is working correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants