简体   繁体   English

使用 Azure blob 存储时应该在本地保存什么?

[英]What should I be saving locally when I use Azure blob storage?

I'm using Azure Blob Storage to allow users to upload files from a web app.我正在使用 Azure Blob 存储来允许用户从 Web 应用上传文件。

I've got them uploading into a container, but I'm not sure what would be best to save on the web app's database since there are multiple options.我已将它们上传到容器中,但我不确定最好将什么保存在 Web 应用程序的数据库中,因为有多个选项。

There is a GUID for the file, but also a URL.文件有一个 GUID,还有一个 URL。

The URL can be used to get to the file directly, but is there a risk that it could change? URL 可用于直接访问文件,但是否存在更改的风险?

If I store the file GUID I can use that to get the other details of the file using an API, but of course that's and extra step compared to the URL.如果我存储文件 GUID,我可以使用它来使用 API 获取文件的其他详细信息,但与 URL 相比,这当然是额外的步骤。

I'm wondering what best practices are.我想知道什么是最佳实践。 Do you just store the URL and be done with it?您是否只是存储 URL 并完成它? Do you store the GUID and always make an extra call whenever a page loads to get the current URL?您是否存储 GUID 并在页面加载时始终进行额外调用以获取当前 URL? Do you store both?你两个都保存吗? Is the URL something constant that can act just as good as a GUID? URL 是否可以像 GUID 一样保持不变?

Any suggestions are appreciated!任何建议表示赞赏!

If you upload any file on azure blob it will give you Url to access it which contains three part如果您在 azure blob 上上传任何文件,它将为您提供 URL 以访问它,其中包含三部分

         {blob base url}/{Container Name}/{File Name}

eg例如

https://storagesamples.blob.core.windows.net/sample-container/logfile.txt https://storagesamples.blob.core.windows.net/sample-container/logfile.txt

SO you can save Blob base url and container name in config file and only the file name part in data base.因此,您可以在配置文件中保存 Blob 基本 url 和容器名称,而在数据库中仅保存文件名部分。

and at run time you can create whole url and return it back to user.在运行时,您可以创建整个 url 并将其返回给用户。

So in case if you are changing blob or container you just need to change it in config file.因此,如果您要更改 blob 或容器,则只需在配置文件中更改它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从“WindowsAzure.Storage”迁移时,我应该为 Azure 表使用什么 package - What package should I use for Azure Tables when migrating away from "WindowsAzure.Storage" Azure存储Blob,C#,如何确定当前使用的Blob? - Azure storage blobs, C#, how can I determine what blob is currently in use? 将映像上传到Azure Blob存储-本地工作,部署后失败 - Uplod images to azure blob storage - Works locally, fails when deployed 将MemoryStream保存到Azure Blob存储 - Saving a MemoryStream to Azure blob storage 当我使用依赖项时,Azure 函数停止工作,在本地工作 - Azure Function stops working when I use dependencies, works locally Azure Blob 存储 - 上传 Blob 后如何获取 Blob 存储 ID? - Azure Blob Storage - how do I get the Blob Storage ID after uploading a blob? 我应该使用哪种类型来使用C#保存图像? - What type should I use for saving images using C#? 将数据表保存到Azure Blob时如何使用GZip - How to use GZip when saving datatable to Azure blob 什么是 [Serializable],我应该什么时候使用它? - What is [Serializable] and when should I use it? 什么是MvcHtmlString,我应该何时使用它? - What is an MvcHtmlString and when should I use it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM