It's a simple solution. Well, it's true. Why do this? With the booming development of mobile Web, there are too many applications that require users to upload image files on mobile Web. Because of this, we have some difficulties to overcome:
When overcoming some of the above difficulties, we can also ask ourselves some questions:
Combining the above difficulties and questions with our actual cases, we may be able to do this: When users upload pictures, compress the pictures before they are submitted to the background. After the picture file size is reduced, the upload speed will naturally increase. Under the same concurrency, the background processing speed will also be improved, and the user experience will be improved. Some people may ask, why not use some mainstream CDN form functions to upload files directly to CDN? Of course, you can choose that solution. I just chose one of the many solutions to use. Or is this the nature of programmers? Prepare As mentioned above, "When users upload pictures, they are compressed before being submitted to the backend." Let's prepare various tools right away:
How to do it?
When calling localResizeIMG, you can specify the width, height, and quality of the compressed image (refer to the documentation for details). As for how to submit the data to the background, you can refer to the solution mentioned in the wiki of the library. Everything is very simple. Demo address The warehouse address for this example The solution in this article is not the only one, nor is it necessarily the best one. If you encounter problems when using related frameworks/libraries, you can go to the corresponding Github repository to view the issue or wiki. |
<<: The closure of domestic online storage has made users worry about where the next outlet will be.
>>: Android unit testing - verify the correct posture of function parameters and return values
At 8 p.m. on April 1, the famous crosstalk perfor...
1. Ideas for event promotion planning 1. Five ele...
I must be honest, this article is the most time-c...
For independent developers, it is very normal to ...
For the die-hard fans of Dragon Ball, it is not e...
1. Vgo micro poster A practical app for making po...
Scenario restoration: A music APP offers a 7-day ...
[[375159]] Preface Today, we will continue to imp...
1. If you want to find real users, pay for the ap...
Course Catalog Day 01: The technique of “stopping...
A good product may not be known to anyone. After ...
"Formula for going viral": creating sur...
Source code introduction: Through the call of cod...
Tik Tok is addictive, don't get addicted to i...
When operating a community , the following steps ...