'Laravel-how to upload image to cloudinary with queue?

I use laravel version 9. I want to upload image in Cloudinary but with laravel (job) queue. So It will upload image in background . Thanks



Solution 1:[1]

You can put the upload code inside a Laravel Job and run the job asynchronously. Just make sure the job's timeout is enough to upload a large file.

Also (pretending you've installed the Cloudinary Laravel package), you can use the 'async'=> true, in the upload parameters to make the upload asynchronous. Then, once the upload is done, cloudinary servers will reach out the notification_url webhook with the file data

 (new UploadApi())->upload($url, [
            'cloud_name'    => '...',  
            'resource_type' => 'auto',
            'async'         => true,
            'notification_url' => route('your.webhook.route'),//when the upload is done
        ]);

For more infos about the picker's options, you can check their doc here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ml59