如果存在Blob名称,则Azure Blob上传重命名 [英] Azure blob upload rename if blob name exist
本文介绍了如果存在Blob名称,则Azure Blob上传重命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Azure blob上传中,如果您上传具有相同文件名(在相同容器中)的新文件,则文件将被覆盖.
In Azure blob upload, a file is overwritten if you upload a new file with the same file name (in the same container).
我想在保存新文件之前重命名它,以避免覆盖任何文件-这可能吗?
I would like to rename the new file before saving it, to avoid overwriting any files - Is this possible?
场景:
- 将文件"Image.jpg"上传到容器"mycontainer"
- 将文件"Image.jpg"上传到容器"mycontainer"(具有不同的内容)
- 在将第二个"Image.png"重命名为"Image_ {guid} .jpg"之前,将其保存到"mycontainer".
推荐答案
需要重命名可能表示存在反模式.如果您的最终目标是在下载时更改文件名,则可以这样做,并保持Blob名称抽象且唯一.
Needing to rename may be indicative of an anti-pattern. If your ultimate goal is to change the name of the file when downloaded, you can do so and keep the blob name abstract and unique.
您可以通过使用
attachment;filename="yourfile.txt"
这将确保在以公共或SAS url访问Blob时设置了标头.
This will ensure that the header is set when the blob is accessed either as public or a SAS url.
这篇关于如果存在Blob名称,则Azure Blob上传重命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文