Git Product home page Git Product logo

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

php-sdk's People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-sdk's Issues

貌似api提供的有点少了

有几个问题 (主要是大文件,流的操作, 要不然 php会爆的)

  • 都是文件上传, 支持流上传么.
  • 大文件上传 支持(考虑php效率 支持分片流上传)?
  • 大文件读取

输出注释文档的 markdown 格式

目前,文档生成是通过 php vendor/bin/phpdoc -d src -t docs,得到 html 格式的文档,需要转化成 markdown 格式,便于 github 展示

不支持 Laravel 8.0

➜ antic-api php -d memory_limit=-1 /usr/local/bin/composer require upyun/sdk
Using version ^3.5 for upyun/sdk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[7.0.1, 6.5.x-dev].
- Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.0.1].
- upyun/sdk 3.5.0 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- Installation request for upyun/sdk ^3.5 -> satisfiable by upyun/sdk[3.5.0].
- Installation request for guzzlehttp/guzzle (locked at 7.0.1, required as ^7.0.1) -> satisfiable by guzzlehttp/guzzle[7.0.1].

Installation failed, reverting ./composer.json to its original content.
➜ antic-api

Allow international customer?

Hi — I have a project that (one day might) need to have an agile CDN and/or compute core out of mainland China. I found your site via GitCafe.

But it seems I cannot sign up due to my phone number, as I tried:
+1 415 000 0000
+1 (415) 000-0000
00 1 415 000 0000
001 ...

It appears the offending regex is:

ng-pattern="/^(1(([358][0-9])|(47)|[8][01236789]))\d{8}$/"

Do you allow international customers?

[ I'm also not sure what "..QQ" is, Google can't translate it. ]

视频

可以支持视频上传功能吗

上传图片和上传其他格式文件返回的响应头不同问题

php7.1.7
laravel5.5
macos 系统最新版
chrome浏览器
laravel-admin 1.5.*
bootstrap file input 插件上传

我现在上传图片的时候一切正常 但是上传其他文件的时候得不到返回的路径 用debug 跟发现问题应该是出现这个方法中(也不一定是你们写的有问题) :

image

这个方法中$headers 上传图片文件和上传其他文件时候不一样
上传图片时候如图:
image

上传其他文件时候headers内容如下图:
image

这样根据上面的代码 如果上传的不是图片 那么返回值为空数组 也导致了我出现上传非图片之后的东西时候获取不到 返回的路径的问题 , 希望大大们 帮忙看看 🙏

压缩解压缩功能 $source参数 如何使用?

异步云处理处理接口必须提供 $source,$tasks

但是压缩解压缩没有$source参数,他们都包含在tasks中,请问这个参数怎么传合适?

    /**
     * 异步云处理
     *
     * 该方法是基于[又拍云云处理](http://docs.upyun.com/cloud/) 服务实现,可以实现音视频的转码、切片、剪辑;文件的压缩解压缩;文件拉取功能
     *
     * 注意:
     * - 所有需要调用该方法处理的资源,必须已经上传到云存储服务
     * - 使用 `process` 之前,必须配置 `config->processNotifyUrl`,否则会提交任务失败
     *
     * 例如视频转码:
     * ```
     *  process($source, array(
     *    array(
     *        'type' => 'video',  // video 表示视频任务, audio 表示音频任务
     *        'avopts' => '/s/240p(4:3)/as/1/r/30', // 处理参数,`s` 表示输出的分辨率,`r` 表示视频帧率,`as` 表示是否自动调整分辨率
     *        'save_as' => '/video/240/new.mp4', // 新视频在又拍云存储的保存路径
     *    ),
     *    ... // 同时还可以添加其他任务
     * ))
     * ```
     *
     * @param string $source 需要预处理的图片、音视频资源在又拍云存储的路径
     * @param array $tasks 需要处理的任务
     *
     * @return array 任务 ID,提交了多少任务,便会返回多少任务 ID,与提交任务的顺序保持一致。可以通过任务 ID 查询处理进度。格式如下:
     * ```
     * array(
     *     '35f0148d414a688a275bf915ba7cebb2',
     *     '98adbaa52b2f63d6d7f327a0ff223348',
     * )
     * ```
     */
    public function process($source, $tasks)
    {
        $video = new Api\Pretreat($this->config);
        return $video->process($source, $tasks);
    }

建议,支持 thephpleague 的 Flysystem

参见 Flysystem

Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one. Technical debt is reduced as is the chance of vendor lock-in.

Goals

  • Have a generic API for handling common tasks across multiple file storage engines.
  • Have consistent output which you can rely on.
  • Integrate well with other packages/frameworks.
  • Be cacheable.
  • Emulate directories in systems that support none, like AwsS3.
  • Support third party plugins.
  • Make it easy to test your filesystem interactions.
  • Support streams for big file handling

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.