akamai-open/netstorage 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

akamai-open/netstorage

Composer 安装命令:

composer require akamai-open/netstorage

包简介

Akamai NetStorage

README 文档

README

Important

Akamai does not maintain or regulate this package. While it can be incorporated to assist you in API use, Akamai Technical Support will not offer assistance and Akamai cannot be held liable if issues arise from its use.

Overview:

This library provides the following NetStorage tools

  • a FlySystem adapter for NetStorage ObjectStore (\Akamai\NetStorage\ObjectStoreAdapter) and FileStore (\Akamai\NetStorage\FileStoreAdapter)
  • a request signer (\Akamai\NetStorage\Authentication)
  • a Guzzle middleware for transparently signing requests to the API (\Akamai\NetStorage\Handler\Authentication)

To Do:

  • A PHP streams layer, so you can use netstorage.fs://path with any built-in I/O functions (e.g. fopen, fread(), and fputs, or file_get_contents() and file_put_contents())

Installation

Installation is done via composer:

$ composer require akamai-open/netstorage

Using the Request Signer

$signer = new Akamai\NetStorage\Authentication();
$signer->setKey($key, $keyName);
$signer->setPath('/' .$cpCode. '/path/to/file');
$signer->setAction('upload');
$headers = $signer->createAuthHeaders();

/*
Return:
[
    'X-Akamai-ACS-Auth-Data' => $authData,
    'X-Akamai-ACS-Auth-Sign' => $signature
];
*/

Using the Guzzle Middleware

To use the middle, add it to the handler stack in the \GuzzleHttp\Client or \Akamai\Open\EdgeGrid\Client options:

$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
]);

// Upload a file:
// Request signature is added transparently
// All parent directories must exist (e.g. /path/to)
$client->put('/' . $cpCode . '/path/to/file', [
    'headers' => [
        'X-Akamai-ACS-Action' => 'version=1&action=upload&sha1=' .sha1($fileContents)
    ],
    'body' => $fileContents
]);

Using the FlySystem Adapters

The simplest way to interact with NetStorage ObjectStore or FileStore is using the \Akamai\NetStorage\ObjectStoreAdapter or \Akamai\NetStorage\FileStoreAdapter for FlySystem.

$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
]);

$adapter = new \Akamai\NetStorage\ObjectStoreAdapter($client, $cpCode);
$fs = new \League\Flysystem\Filesystem($adapter);

// Upload a file:
// cpCode, action, content signature, and request signature is added transparently
// Additionally, all required sub-directories are created transparently
$fs->write('/path/to/file', $fileContents);

Please note that $key, $keyName & $host can be obtained from "NetStorage API Information" page: https://control.akamai.com/storage/customer_portal.jsp?content_page=ns_api_info.jsp

akamai-open/netstorage 适用场景与选型建议

akamai-open/netstorage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 305.09k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2015 年 09 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 akamai-open/netstorage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 akamai-open/netstorage 我们能提供哪些服务?
定制开发 / 二次开发

基于 akamai-open/netstorage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 305.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 9
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: Apache
  • 更新时间: 2015-09-18