PHP Classes

File: application/modules/extensions/aws/Aws/Signature/S3SignatureV4.php

Recommend this page to a friend!
  Classes of Tran Tuan   Pretty PHP S3 Files Manager   application/modules/extensions/aws/Aws/Signature/S3SignatureV4.php   Download  
File: application/modules/extensions/aws/Aws/Signature/S3SignatureV4.php
Role: Application script
Content type: text/plain
Description: Application script
Class: Pretty PHP S3 Files Manager
Web based interface to manage files in Amazon S3
Author: By
Last change:
Date: 8 years ago
Size: 1,132 bytes
 

Contents

Class file image Download
<?php
namespace Aws\Signature;

use
Aws\Credentials\CredentialsInterface;
use
Psr\Http\Message\RequestInterface;

/**
 * Amazon S3 signature version 4 support.
 */
class S3SignatureV4 extends SignatureV4
{
   
/**
     * Always add a x-amz-content-sha-256 for data integrity.
     */
   
public function signRequest(
       
RequestInterface $request,
       
CredentialsInterface $credentials
   
) {
        if (!
$request->hasHeader('x-amz-content-sha256')) {
           
$request = $request->withHeader(
               
'X-Amz-Content-Sha256',
               
$this->getPayload($request)
            );
        }

        return
parent::signRequest($request, $credentials);
    }

   
/**
     * Override used to allow pre-signed URLs to be created for an
     * in-determinate request payload.
     */
   
protected function getPresignedPayload(RequestInterface $request)
    {
        return
'UNSIGNED-PAYLOAD';
    }

   
/**
     * Amazon S3 does not double-encode the path component in the canonical request
     */
   
protected function createCanonicalizedPath($path)
    {
        return
'/' . ltrim($path, '/');
    }
}