Home > Backend Development > PHP Tutorial > Cloud Storage: Comparison between Alibaba Cloud and Qiniu_PHP Tutorial

Cloud Storage: Comparison between Alibaba Cloud and Qiniu_PHP Tutorial

WBOY
Release: 2016-07-20 11:15:23
Original
1103 people have browsed it

Conclusion:

  阿里云存储 七牛云存储
标准:REST、HTTP 99%符合 50%
基本功能:送二级域名、绑定域名、CDN 支持 支持
自定义文件HTTP header 支持 少量支持
高级服务:图片处理 不提供 很完善地提供
收费策略 收费 小流量免费。大流量收费。
官方PHP SDK 差,依赖亚马逊http库,而不是PHP官方PEAR HTTP_Request2

Rewrite the official confusing PHP SDK of Alibaba Cloud Storage into PEAR, and then download it as an apk.

Then I want to migrate the picture server to cloud storage so that it does not occupy VPS bandwidth. Only then did I discover that Alibaba Cloud OSS only has the simplest file storage function and does not support image processing.

For example, the most commonly used functions of image servers:

1. Upload an original image and automatically generate various images of any resolution in real time

For example, the original picture

http://example.com/2.jpg

Then request any resolution, and the server will automatically generate and output it when requesting, such as

http://example.com/2.jpg?resolution=1280x720

2. Automatic format conversion

For example http://example.com/2.jpg?format=png

Since Alibaba Cloud Storage does not support the image function, it cannot be used. Consider migrating to Qiniu.

Refer to Qiniu official PHP SDK, rewrite it into PHP PEAR package, and find that Qiniu API is not REST.

API comparison is as follows:

  阿里云存储 七牛云存储
上传文件 HTTP PUT 资源URI HTTP POST up.qiniu.com
删除文件 HTTP DELETE 资源URI HTTP POST rs.qbox.me
认证 HTTP header Authorization 一会儿使用HTTP header Authorization,一会儿使用POST token

Alibaba Cloud Storage API CURL demo:

Upload files:

curl -i -X <span '</span><span PUT</span><span '</span> -T <span '</span><span 1.jpg</span><span '</span> <span '</span><span http://com-163-sinkcup.oss.aliyuncs.com/1.jpg</span><span '</span> -H <span '</span><span Authorization: OSS asdf:qwer</span><span '</span> -H <span '</span><span Content-Type:image/jpeg</span><span '</span>
Copy after login

curl -i -X <span '</span><span DELETE</span><span '</span> <span '</span><span http://com-163-sinkcup.oss.aliyuncs.com/2.jpg</span><span '</span>
Copy after login

Qiniu Cloud Storage API CURL demo:

Upload files (it can be seen that Qiniu puts the bucket in the token authentication, which technically prevents Qiniu from achieving "public upload"):

curl -i -F <span '</span><span file=@2.jpg</span><span '</span> -F <span '</span><span token=asdf</span><span '</span> -F <span '</span><span key=2.jpg</span><span '</span> <span '</span><span http://up.qiniu.com/</span><span '</span>
Copy after login

curl -i -X <span '</span><span POST</span><span '</span> -H <span '</span><span Authorization: QBox asdf</span><span '</span> <span '</span><span http://rs.qbox.me/delete/com-163-sinkcup:1.jpg</span><span '</span>
Copy after login

It can be seen that Alibaba Cloud Storage is technically rigorous and uses standard REST. Qiniu no longer uses tokens in some places, but uses HTTP header Authorization, which may be being improved.

The picture function comparison is as follows:

Alibaba Cloud Storage Qiniu
  阿里云存储 七牛云存储
自动生成任意分辨率 支持
自动生成任意格式 支持
webp 支持,可节约app大量流量
Cloud Storage
Automatically generate any resolution None Support
Automatically generate any format None Support
webp None Supported, can save a lot of app traffic

Qiniu’s picture demo:

Original image 103KB: http://com-163-sinkcup.qiniudn.com/6ffe255fab20747c8872638870268703

Automatically generate jpg 79KB: http://com-163-sinkcup.qiniudn.com/6ffe255fab20747c8872638870268703?imageMogr/v2/auto-orient/thumbnail/1366x768/quality/80/format/jpg

Automatically generate webp 23KB: http://com-163-sinkcup.qiniudn.com/6ffe255fab20747c8872638870268703?imageMogr/v2/auto-orient/thumbnail/1366x768/quality/80/format/webp

Because the image function provided by Qiniu is extremely powerful, supporting webp is particularly important for saving traffic on the mobile Internet (Android and ios apps save 70% traffic), and Qiniu uses the Go language and wrote a book ("Go Language Programming》Douban), indicating that it is technically very strong and will support REST in the future, so I finally decided to use Qiniu Cloud Storage.

The PHP SDKs of Alibaba Cloud and Qiniu are both non-standard and cannot be used, so they can only be rewritten. I rewrote it, here it is:

Qiniu Cloud Storage PHP PEAR package download: http://www.cnblogs.com/sink_cup/p/PHP_PEAR_Services_Qiniu.html

Alibaba Cloud Storage PHP PEAR package download: http://www.cnblogs.com/sink_cup/p/PHP_PEAR_Services_Aliyun_OSS.html

1% of Alibaba Cloud Storage does not meet standards:

The custom HTTP header uses lowercase letters, which is inconsistent with HTTP common sense. For example, it is wrong for Alibaba Cloud to use x-oss-acl, and X-Oss-Acl should be used.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440204.htmlTechArticleConclusion: Alibaba Cloud Storage Qiniu Cloud Storage Standard: REST, HTTP 99% complies with 50% Basic functions: get two free Level domain name, bound domain name, CDN supports custom files, HTTP header supports less...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template