I am using the Azure\azure-storage-php
library for PHP to upload a blob file (image or video in my case) to the Azure Blob Storage. The file is uploaded from a mobile app using a multipart API call to the server which then uploads it to the blob storage.
The problems in this scenario are:
- The file takes double the time to upload, as it is fully uploaded at first to the server then from the server to Azure.
- Once uploaded to the server, a success response (HTTP 200) is returned to the mobile app (from our server API). But actually the file is not yet available in Azure and might take some time depending on its size to be ready.
What I'm looking for is a way to 'stream' the file immediately from the multipart to azure (as a pass-through) to prevent this 'double upload' scenario.
I don't want to give the mobile app the direct link to the blob storage to prevent abuse, in addition I need to perform extra checks (ex mimetype
checking) which is why I need the server in between.
Is this achievable?
For reference, here's the sample I'm using (my code is basically the same): storage-blobs-php-quickstart/blob/master/phpQS.php.