gpt4 book ai didi

Azure 休息 API。如何创建文件夹并检查文件夹是否存在?

转载 作者:行者123 更新时间:2023-12-03 04:51:09 31 4
gpt4 key购买 nike

我想使用 azure blob Rest api 创建文件夹,并且还想检查文件夹是否存在。

Hierarchy:

arjun/images/
arjun/Videos/001.avi
arjun/Vidos/002.avi
img001.jpg

I tried to send a PUT request in order to create a folder with path for example "arjun/images/":

  1. This creates a folder but its not empty.
  2. It is creating an empty file with no name inside the folder.

现在,即使这是正确的,另一个问题是当我想检查文件夹是否存在时:

  1. 我正在发送列表 Blob 调用,前缀为文件夹路径。
  2. 现在的问题是区分空文件夹和不存在的文件夹,因为如果请求格式正确,它将始终是 200 Ok 消息,其中 Blob 元素为空

So, can't tell whether a folder doesn't exists or is empty.

i.e. a blob list request with prefix "arjun/xyz/" and "arjun/images/ both will be successful but will have response body empty as both doesn't contain any content. But, in reality first folder xyz doesn't exist and second folder exists but empty.

最佳答案

The Blob service is based on a flat storage scheme, not a hierarchical scheme.

来源:Blob Names

这清楚地表明,Azure 存储 Blob 实际上没有文件夹层次结构,“文件夹”只是用于创建虚拟层次结构的虚拟目录。

此外,如果您尝试使用 Microsoft 存储资源管理器创建虚拟目录,它还会向您突出显示,在将 Blob 放入其中之前,虚拟目录不存在,这是非常有意义的,因为虚拟目录位于fact 只是 blob 名称的一部分。

总之,如果您“创建”虚拟目录而不向其中上传任何 blob,则该虚拟目录不存在。

enter image description here

关于Azure 休息 API。如何创建文件夹并检查文件夹是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42059177/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com