Azure PHP SDK:在单个zip文件中下载容器的所有blob [英] Azure PHP SDK: download container's all blob in a single zip file

查看:47
本文介绍了Azure PHP SDK:在单个zip文件中下载容器的所有blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从指定容器中下载所有blob作为zip文件. 有什么方法可以直接从Azure下载zip文件,而无需在我的服务器上进行处理?

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?

目前我认为如下:

file_put_contents("file_name", get_file_contents($blob_url));

我将所有文件存储在服务器上,然后创建这些文件的zip文件,然后将强制下载.

I will store all files on my server and then create zip file of those and then will force to download. .

推荐答案

Azure没有这样的功能来为您生成一堆blob的zip文件. Azure存储只是...存储.您需要通过php sdk(或选择直接通过api)下载每个blob.

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).

如果要压缩内容,则需要先压缩内容,然后再存储到Blob存储中.

And if you want the content zip'd, you'll need to zip the content prior to storing in blob storage.

您的代码(在您的问题中)将无法按原样工作,因为get_file_contents()希望与文件I/O一起使用,而这不是与Blob交互的方式.相反,您将执行以下操作:

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());

这篇关于Azure PHP SDK:在单个zip文件中下载容器的所有blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆