emstorage/php-sdk 问题修复 & 功能扩展

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

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

emstorage/php-sdk

最新稳定版本:v3.1

Composer 安装命令:

composer require emstorage/php-sdk

包简介

无描述信息

README 文档

README

PHP SDK for http://fr.emstorage.com

Install

composer require emstorage/php-sdk:dev-master 

A stable version will eventually be released one day...

Create a client

With Silex

You can use the service provider:

<?php use Emonsite\Emstorage\PhpSdk\Bridge as EmStorageServiceProvider; $app->register(new EmStorageServiceProvider(), [ 'emstorage.applications' => [ 'yourAppName' => [ 'public_key' => 'appPublicKey', 'private_key' => 'appPrivateKey', ] ], 'guzzle.options' => [ 'debug' => false, ] ]); 

For each applications it will create a service named "emstorage.yourAppName"

Or manually

<?php use Awelty\Component\Security\HmacSignatureProvider; use Emonsite\Emstorage\PhpSdk\Client; // Emstorage use hmac authentification with sha1 as algo $signatureProvider = new HmacSignatureProvider($publicKey, $privateKey, 'sha1'); // create as many clients as you need (typically one per EmStorageApplication) $emStorage = new Client($authenticator, $someGuzzleConfig = []); 

Usage

The client has one subclient per resource in EmStorage. TODO: one doc file per resource

ObjectClient

  • Create a file (it will throw an exception if the file already exist - TODO)
/** @var ObjectSummaryInterface $file **/ $file = $emStorage->object->create($path, $content);
  • Update a file (it will throw an exception if the file doesn't exist - TODO)
/** @var ObjectSummaryInterface $file **/ $file = $emStorage->object->update($path, $content);
  • Delete a file (it will throw an exception if the file doesn't exist - TODO)
$emStorage->object->delete($path);
  • Get a file metadatas
/** @var ObjectSummaryInterface $file **/ $file = $emStorage->object->getObject($path);
  • Get a list
/** @var Collection|ObjectSummaryInterface[] $files **/ $files = $emStorage->object->getObjects($offset = 0, $limit = 5);

You also can work with models (ObjectSummaryInterface)

  • Create a file
$file = new EmObject(); $file->setFilename($path); $remoteFile = $emStorage->object->createFromObject($file); // warning: returned $remoteFile is not the same instance as $file, TODO ? 

Feel free to exlore the client with your IDE to find some other methods to create, get or delete file from object or objectId.

Models

ObjectSummaryInterface

This is the interface you work with when you send files.

<?php interface ObjectSummaryInterface { /** * @return string */ public function getId(); /** * @return string */ public function getFilename(); /** * @return string */ public function getPublicUrl(); /** * @return string */ public function getMime(); /** * @return float */ public function getSize(); /** * @return string */ public function getSizeHuman(); /** * @return array */ public function getMeta(); } 

Collection

A collection of ObjectSummaryInterface.

class Collection implements \ArrayAccess, \Countable, \Iterator { }

It also provide nav and links properties:

$files = $emStorage->object->getObjects(); print_r($files->getNav()); /* Array (  [total] => 38  [count] => 5  [offset] => 0  [limit] => 5  // TODO need [totalPage] ? ) */ print_r($files->getLinks()); /* Array (  [prev] =>   [next] => /objects?offset=5&limit=5  // TODO need [nextOffset] ? ) */

To be continued...

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-01-04