Php uploads pictures in batch

each record has a remote url image address when doing excel import. I need to download the picture to my own server
it takes too long for users to import io such as file_get_contents.
is there a good solution?

Oct.17,2021

A queue hangs in the background and throws the URL that needs to be downloaded into the queue. Use the queue to download and save it after the download is complete.


1. First of all, it is recommended that you do not store pictures on Synchronize. It is best to do an asynchronous task to download and store pictures

.

2. For network requests, cURL libraries can be used instead of file_get_contents,cURL, which is superior to file_get_contents in performance, speed and stability.


Import the data first. Then make N processes to collect pictures. This will be quick. It's carried out in batches. The speed should be very fast.


thank you very much for your answers, as the comment said:
the solution at that time was to use the redis queue to download and store pictures asynchronously

Menu