Azure PHP SDK: download container's all blob in a single zip file

非 Y 不嫁゛ 提交于 2019-12-22 16:13:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!