Home > WeChat Applet > Mini Program Development > How to quickly connect WeChat applet to Qiniu Cloud

How to quickly connect WeChat applet to Qiniu Cloud

高洛峰
Release: 2017-02-09 14:08:39
Original
2705 people have browsed it

On January 9, the WeChat mini program was officially released. The mini program finally unveiled its mysterious veil, and developers are even more enthusiastic about the mini program.

Judging from the popular application scenarios of small programs, they can be roughly divided into two categories. One is low-frequency apps, such as financial banking or insurance company apps, and O2O door-to-door cooking and housekeeping apps. Apps; the other category is apps that are frequently used but have simple functions, such as tool-based weather and express query apps, and rich-media information apps.

So, who will be the big winner of mini programs? To create a unicorn-level WeChat mini program, developers must not only focus on the application scenarios of the mini program and the innovation of their own business logic, but also pay attention to the improvement of user experience. The user experience of the front end of the mini program is closely related to the backend that supports the mini program. End services are closely related.

Why do mini programs need to be connected to the cloud?

Currently, developers mainly encounter the following problems when developing mini programs:

The mini program release size exceeds the limit

WeChat officially limits the release of mini programs The code cannot exceed 1MB. In the actual development process, ordinary small programs will inevitably have rich media files such as pictures, and these rich media files will occupy a large amount of storage space, eventually causing the entire uploaded package to exceed the limit. Therefore, developers need to upload the rich media data that comes with the code to the cloud for storage, so that the mini program can be truly "small".

Insufficient storage space

For small programs that support UGC, users will generate a large amount of interactive data every day, and the capacity of their own storage servers is insufficient, so there is a need to store massive data.

Slow file loading speed

For small programs that contain a large amount of rich media data, files such as pictures are slow to load when used by the client. Users complain about the poor experience of using small programs, thus creating a data network The need for acceleration.

Since the release of the WeChat mini program for internal testing, Qiniu Cloud has paid close attention to the development and application of the mini program. This article will tell you how to quickly connect the mini program to Qiniu.

Qiniu Cloud Mini Program Upload SDK

First of all, easy uploading of mini programs to the cloud is required. To meet the needs of uploading rich media data, Qiniu Cloud provides mini program upload SDK, so developers can save money. To adapt to the development work of the WeChat upload interface, you only need to add the encapsulated code to easily migrate to the cloud. According to the WeChat Mini Program SDK Guide, only the following two steps are needed to achieve access.

The first step, basic preparation

A public account that can access the mini program

Register a Qiniu Cloud account and create a space

Qiniu WeChat Mini Program SDK

The second step is to configure the domain name information on the Mini Program official website

Log in to the WeChat public platform, go to Settings-Development Settings, and click the modification link under Server Configuration

Modify uploadFile legal domain name (for example, the North China https upload address is: https://up-z1.qbox.me, please refer to the official document for detailed address information)

If you want to download a file, you need to set the downloadFile legal domain name for you at the same time Bucket download address

Save settings

How to quickly connect WeChat applet to Qiniu Cloud

[Note] WeChat currently limits the domain name whitelist to only three modifications per month

Third Step, the mini program accesses the upload function

Clone gpake/qiniu-wxapp-sdk warehouse:

git clone https://github.com/gpake/qiniu-wxapp-sdk.git

Find the qiniuUploader.js file in the SDK directory, and reference the qiniuUploader.js file on the page where you need to use the upload function. The sample code is as follows:

How to quickly connect WeChat applet to Qiniu Cloud

How to quickly connect WeChat applet to Qiniu Cloud

Preview of running effects

How to quickly connect WeChat applet to Qiniu Cloud

After connecting to Qiniu, the mini program can not only enjoy elastic, easy-to-scale, safe and highly available storage space, but also Qiniu provides It provides a one-stop solution for data processing, data upload and download acceleration, making your mini program "small" enough while also improving the user experience of the mini program.

For more related articles on how to quickly connect WeChat applet to Qiniu Cloud, please pay attention to the PHP Chinese website!

Related labels:
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