从Azure的Blob存储下载文件 [英] Download File from Azure Blob Storage

查看:669
本文介绍了从Azure的Blob存储下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,允许用户上传照片,存储在Azure的Blob存储。用户还可以查看这些照片的能力。要查看它们,我们希望将图像下载到默认下载位置的应用程序。目前,上传的作品完美。但是,我发现的Azure API下载功能似乎并没有被做任何事情。另外,我真的不能,因为此功能需要在台式机/笔记本电脑,以及对具有不同的默认目录移动设备的工作指定下载位置。

I have an application that allows users to upload photos, which are stored in Azure Blob Storage. The user also has the ability to view these photos. To view them, we want the application to download the image to the default download location. At the moment, the upload works perfect. But the download function that I found for Azure API doesn't seem to be doing anything. Also, I can't really specify a download location because this functionality needs to work on desktop/laptops as well as on mobile devices which have different default directories.

这似乎应该是简单,但我无法找到任何东西来帮助我。

This seems like it should be simple but I cannot find anything to help me.

下面是我的code的样本:

Here is a sample of my code:

CloudBlobContainer container = blobClient.GetContainerReference("photos");
CloudBlob blob = container.GetBlobReference(photo.BlobUrl);
//copy blob from cloud to local gallery
blob.DownloadToFile(photo.ImageName);

blob.DownloadToFile(photo.ImageName); 将导致服务器请求,但没有任何反应,又名没有文件下载

The blob.DownloadToFile(photo.ImageName); causes a server request but nothing happens, aka no file is downloaded.

推荐答案

您不能在客户端直接从Blob存储下载的文件,并使用内置的浏览器功能保存它的任何理由吗?如果文件是私人的,它是pretty容易产生SAS签名。这将从通过您的服务器来卸载下载和删除开销。

Any reason you cannot have the client download the file directly from blob storage and use the built-in browser capability to save it? If the files are private, it is pretty easy to generate a SAS signature. This will offload the download from coming through your server and remove that overhead.

这篇关于从Azure的Blob存储下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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