search
HomeBackend DevelopmentPHP TutorialCloud Storage: Comparison between Alibaba Cloud and Qiniu_PHP Tutorial

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>

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>

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>

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>

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...
Statement
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
How do you modify data stored in a PHP session?How do you modify data stored in a PHP session?Apr 27, 2025 am 12:23 AM

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Give an example of storing an array in a PHP session.Give an example of storing an array in a PHP session.Apr 27, 2025 am 12:20 AM

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

How does garbage collection work for PHP sessions?How does garbage collection work for PHP sessions?Apr 27, 2025 am 12:19 AM

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

How can you trace session activity in PHP?How can you trace session activity in PHP?Apr 27, 2025 am 12:10 AM

Tracking user session activities in PHP is implemented through session management. 1) Use session_start() to start the session. 2) Store and access data through the $_SESSION array. 3) Call session_destroy() to end the session. Session tracking is used for user behavior analysis, security monitoring, and performance optimization.

How can you use a database to store PHP session data?How can you use a database to store PHP session data?Apr 27, 2025 am 12:02 AM

Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

Explain the concept of a PHP session in simple terms.Explain the concept of a PHP session in simple terms.Apr 26, 2025 am 12:09 AM

PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

How do you loop through all the values stored in a PHP session?How do you loop through all the values stored in a PHP session?Apr 26, 2025 am 12:06 AM

In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

Explain how to use sessions for user authentication.Explain how to use sessions for user authentication.Apr 26, 2025 am 12:04 AM

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!