Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lararocks's avatar

API request execution time

I have a mobile app that makes an http request to Laravel by sending text data, images, and one video. In the Laravel API function, I read the base64 files, save it to storage, and then update the DB.

The problem: The process of writing files takes time and mobile users have to wait for the response from the Laravel API to get the thank you message.

Is there a way where I can return the response to user while the files are being saved to storage to minimize the response time to users?

Thanks

0 likes
9 replies
bobbybouwmann's avatar

The only way I can think of is by separating the request. So one for the text and images (which is a lot faster) and one for the video. Then you can already do something else in your app while the background process is still doing the uploading part.

lararocks's avatar

Thanks for the kind response. I tried that actually but if the user quits the app after the thank you message directly, the video won't upload.

martinbean's avatar

if the user quits the app after the thank you message directly, the video won't upload.

@lararocks So why do you want to show a success message if the request hasn’t completed?

Instead, use multi-part uploading and show a progress bar if the user needs to keep the app open for a file to be uploaded. Then show a success message when the operation has actually succeeded.

sohag-pro's avatar

You can pass the request to a queue to handle it. Then the user will get notified file uploaded as soon as the file is uploaded. User then don't need to wait for processing. You can process the data later and make a notification.

Here is the documentation https://laravel.com/docs/7.x/queues

martinbean's avatar

@shuvo575 A queue doesn’t solve anything here. The actual video needs to be sent from the user’s device to @lararocks’ application. A queue isn’t going to solve that.

sohag-pro's avatar

@martinbean Thanks for mentioning me. As per the problem statement, @lararocks 's system is taking time for writing files. So he can push the writing job in a queue to process it in background. And thus he can send a reply back with success without waiting time for writing the files.

bobbybouwmann's avatar

@shuvo575 You are still incorrect. The file needs to be uploaded from the application to the server first. After that, you can use a queue for sure to process the file or show a success message somewhere.

Have you ever uploaded a video to YouTube? This works the same if the upload is still processing and you close the window it won't be finished ;)

sohag-pro's avatar

@bobbybouwmann Where did I say to send the success message before uploading the file. The problem is the system is taking time for processing after the upload. So, I've said that, it can be send to a queue to process it later. Hope now it's clear to you.

bobbybouwmann's avatar

@shuvo575 This is all about uploading the files, not processing the files on the server itself

The problem: The process of writing files takes time and mobile users have to wait for the response from the Laravel API to get the thank you message.

Please or to participate in this conversation.