[英]Return blob from azure blob storage without saving it
I am trying to get the blob from Azure blob storage and return the files to the user for download. 我正在尝试从Azure blob存储中获取blob,并将文件返回给用户以进行下载。
Now what I am trying to do is to get the file from azure, save it locally, and return the file as using Static file: 现在,我想做的是从azure获取文件,将其保存在本地,然后像使用静态文件一样返回文件:
def getDownload(filename):
try:
file = blob.get_blob('picture', filename)
with open(filename, 'w') as f:
f.write(file)
except:
abort(400, 'Download blob fail')
return static_file(filename, root='.', download=filename)
What I am trying to do it to stream it to user without first saving the file in the server. 我正在尝试将其流式传输给用户,而无需先将文件保存在服务器中。
How can I achieve it? 我该如何实现?
Unfortunately I don't have any python sample code, but here is what you can do for verification purposes: 不幸的是,我没有任何python示例代码,但是您可以按照以下步骤进行验证:
Example: 例:
Client requests http://myservice.cloudapp.net/blobs/somefile.ext and is verified to access the resource. 客户端请求http://myservice.cloudapp.net/blobs/somefile.ext ,并经过验证可以访问资源。 Then he will be redirected to http://mystorage.blob.core.windows.net/container/somefile.ext?SHARED_ACCESS_SIGNATURE .
然后,他将被重定向到http://mystorage.blob.core.windows.net/container/somefile.ext?SHARED_ACCESS_SIGNATURE 。 This link is only available to that client for a few minutes.
该链接仅在几分钟内可供该客户端使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.