定制 mfn/aws-post-v4-sign 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mfn/aws-post-v4-sign

最新稳定版本:0.1

Composer 安装命令:

composer require mfn/aws-post-v4-sign

包简介

Create a signature for Amazon S3 POST API request

README 文档

README

Please use the features of the official AWS SDK PHP https://github.com/aws/aws-sdk-php

Specifically, have a look at https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-post.html

Create V4 signature for AWS S3 REST API Post requests Travis Build Status

Homepage: https://github.com/mfn/php-aws-post-v4-sign

Blurb

This library can create signature for a POST request designated for Amazon Simple Storage (S3) REST API service.

This package does not depend on the AWS PHP SDK. It can only create a signature. Logically, this code exists in similar form inside the SDK, but it's not possible form the outside to leaverage it.

Fore more information see:

Requirements

PHP 5.4

Install / Setup

Using composer: composer.phar require mfn/aws-post-v4-sign 0.1

Example

<?php
use Mfn\Aws\Signature\V4\SignatureV4;

$secret = 'ADFSDFDS3432S23423'; # Your secret key => never share!
$time = time();
$credential = join('/', [
    $accesKeyId, # Your AWS access key ID
    gmdate('Ymd', $time),
    'us-west-1',
    's3',
    'aws4_request',
]);
# Example policy
$policy = [
    'expiration' => gmdate('Y-m-d\TH:i:s\Z', strtotime('+2 hours', $time)),
    'conditions' => [
        ['acl' => 'public-read'],
        ['bucket' => 'your-bucket'],
        ['starts-with', '$key', ''],
        ['x-amz-credential' => $credential],
        ['x-amz-algorithm' => 'AWS4-HMAC-SHA256'],
        ['x-amz-date' => gmdate('Ymd\THis\Z', $time)],
    ],
];

$sigGen = new SignatureV4(
    $secret, # the secret part; never share with anyone!
    $policy
);
$signature = $sigGen->getSignature();

The SignatureV4 class will parse the $policy to that extent to extract the x-awz-credential key, as this credential is an essential part for creating the signature.

As a base64 encoded JSON representation of the $policy is required to create the signature and is usually required for the final request, a method for retrieving it exists: $encodedPolicy = $sigGen->getBase64EncodedPolicy();

Contribute

Fork it, hack on a feature branch, create a pull request, be awesome!

No developer is an island so adhere to these standards:

© Markus Fischer markus@fischer.name

统计信息

  • 总下载量: 7.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-29