[英]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.