问题
I want to download all blob from specified container as a zip file. Is there any way to download its as zip directly from Azure, no need to process it on my server?
Currently I think like below:
file_put_contents("file_name", get_file_contents($blob_url));
I will store all files on my server and then create zip file of those and then will force to download. .
回答1:
Azure has no such facility to generate a zip file for a bundle of blobs for you. Azure Storage is just... storage. You'll need to download each of your blobs via php sdk (or directly via api if you so choose).
And if you want the content zip'd, you'll need to zip the content prior to storing in blob storage.
Your code (in your question) won't work as-is, since get_file_contents()
expects to work with file I/O, and that's not how to interact with blobs. Rather, you'd do something like this:
$getBlobResult = $blobClient->getBlob("<containername>", "<blobname>");
file_put_contents("<localfilename>", $getBlobResult->getContentStream());
来源:https://stackoverflow.com/questions/46323731/azure-php-sdk-download-containers-all-blob-in-a-single-zip-file