Giter Site home page Giter Site logo

upyun-php-sdk's Introduction

又拍云 SDK for PHPer

Build Status Scrutinizer Code Quality Code Coverage

又拍云 PHP SDK,封装了又拍云功能丰富的开放 API ,帮助开发者快速对接文件云端存储、图片音视频云处理、智能鉴黄等功能

功能列表

SDK 包含如下功能

功能列表中的异步操作,均可以设置异步回调通知地址,接收异步处理结果 如果需要测试回调功能,可以通过又拍云回调服务创建一个临时回调地址

使用说明

安装

PHP >= 5.5

1.使用 composer 安装

推荐使用该方法安装,成为优雅的 PHPer 🔥

建议使用速度很快的国内全量镜像(又拍云赞助)

composer require upyun/sdk

2.如果不适应 composer 管理,可以直接下载压缩包(注意需要下载 php-sdk-版本号.zip 格式的 zip 压缩包,不是 Source code 源码压缩包),解压后,项目中添加如下代码:

require_once '/path/to/php-sdk/vendor/autoload.php';

文档

详细文档见 doc.md

示例

先初始化又拍云服务配置:

require_once('vendor/autoload.php'); // 只针对使用 composer 安装
// require_once '/path/to/php-sdk/vendor/autoload.php'; // 针对压缩包安装

use Upyun\Upyun;
use Upyun\Config;
$serviceConfig = new Config('yourServiceName', 'yourOperatorName', 'yourOperatorPwd');
$client = new Upyun($serviceConfig);

字符串写入又拍云服务器

$client->write('/save/path', 'file content');

文件流写入又拍云服务器

$file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);

使用并行式断点续传上传文件

$serviceConfig->setUploadType('BLOCK_PARALLEL');
$client = new Upyun($serviceConfig);
$file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);

上传图片并转换格式为 png,详见上传作图

$file = fopen('/local/path/image.jpg', 'r');
$client->write('/save/image.png', $file, array('x-gmkerl-thumb' => '/format/png'));

下载文件并保存到本地

$saveLocal = fopen('/local/path/image.jpg', 'w');
// 第二个参数不传时,read 方法将直接返回文件内容
$client->read('/remote/server/image.png', $saveLocal);

贡献代码

  1. Fork
  2. 为新特性创建一个新的分支
  3. 发送一个 pull request 到 master 分支

社区

许可证

UPYUN PHP-SDK 基于 MIT 开源协议

http://www.opensource.org/licenses/MIT

upyun-php-sdk's People

Contributors

sabakugaara avatar lfeng avatar our80 avatar lvye avatar timebug avatar phy25 avatar ckaqq avatar khs1994 avatar totoleo avatar forthe2008 avatar yejingx avatar

Watchers

James Cloos avatar leorain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.