Microsoft Azure:如何在 blob 容器中创建子目录
如何在 Blob 容器中创建子目录
,例如
在我的 Blob 容器 http://veda .blob.core.windows.net/document/
如果我存储一些文件,它将是
现在,如何创建子目录
这样我就可以存储文件
How to create a sub directory in a blob container
for example,
in my blob container http://veda.blob.core.windows.net/document/
If I store some files it will be
Now, how to create a sub directory
So that I can store files
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
尝试 Azure 示例时遇到类似问题 第一个无服务器应用。
这是我如何通过删除 $web 前面的 \ 来解决的信息。
注意:启用静态网站时,$web 容器会自动创建。
从未在任何地方见过 $root 容器。
Got similar issue while trying Azure Sample first-serverless-app.
Here is the info of how i resolved by removing \ at front of $web.
Note: $web container was created automatically while enable static website.
Never seen $root container anywhere.
我需要从 Jenkins 管道执行此操作,因此需要将文件上传到特定文件夹名称,而不是上传到根容器文件夹。我使用 --destination-path 可以是 folder 或 folder1/folder2
希望这对某人有帮助
I needed to do this from Jenkins pipeline, so, needed to upload files to specific folder name but not to the root container folder. I use --destination-path that can be folder or folder1/folder2
hope this help to someone
没有直接选项来创建文件夹/目录。但是,如果您希望将某些内容上传到文件夹,那么在上传文件时,您需要在高级部分下传递文件夹名称。例如,如果我想将图像上传到名为文件夹的资产,那么我的上传窗口将如下所示。enter此处图片描述
这将创建一个名为 asset 的文件夹,并将文件上传到该文件夹。需要注意的是文件夹名称和文件名称区分大小写。
There is no direct option to create a folder/directory. But if you wish to upload something to folder then while uploading file you need to pass folder name under advance section. For Example If I want to upload a image to an asset named folder then my upload window will look like this.enter image description here
This will create a folder names asset and will upload file to that folder. And point to be noted is folder name and file name are case sensitive.
正如 @Egon 提到的,
如果您通过 azure 门户上传:
单击上传 >高级>上传到文件夹,例如 dir1/dir2/dir3
检查以下内容:https://i.sstatic.net/Aq5OQ。 .png
As @Egon mentioned,
If you are uploading through azure portal:
click upload > advanced > Upload to folder e.g dir1/dir2/dir3
check this: https://i.sstatic.net/Aq5OQ.png
C#< /a> 而不是上面接受的英语:
在我看来,在 Node.JS 上的 CoffeeScript 中更简单:
C# instead of accepted English above:
In my opinion, it's simpler in CoffeeScript on Node.JS:
要添加 Egon 所说的内容,只需创建名为“folder/1.txt”的 blob,它就会起作用。无需创建目录。
To add on to what Egon said, simply create your blob called "folder/1.txt", and it will work. No need to create a directory.
实际上只有一层容器。您实际上可以创建一个“文件系统”,例如分层存储,但实际上所有内容都将位于一层,即它所在的容器中。
为了创建像存储这样的虚拟“文件系统”,您可以使用包含“/”的 blob 名称,以便您可以按照自己的存储方式执行任何操作。此外,最棒的是,您可以通过给出部分字符串(最多为“/”)来在虚拟级别搜索 blob。
这两件事,向路径添加“/”和用于搜索的部分字符串,一起创建虚拟“文件系统”存储。
There is actually only a single layer of containers. You can virtually create a "file-system" like layered storage, but in reality everything will be in 1 layer, the container in which it is.
For creating a virtual "file-system" like storage, you can have blob names that contain a '/' so that you can do whatever you like with the way you store. Also, the great thing is that you can search for a blob at a virtual level, by giving a partial string, up to a '/'.
These 2 things, adding a '/' to a path and a partial string for search, together create a virtual "file-system" storage.
在 Azure 门户中,我们在上传文件时有以下选项:
In Azure Portal we have below option while uploading file :
@afr0 有一条评论询问如何过滤文件夹。
有两种方法使用 GetDirectoryReference 或循环遍历容器 blob 并检查类型。下面的代码是用 C# 编写的,
请阅读此内容以获取更深入的介绍: http://www.codeproject.com/Articles/297052/Azure-Storage-Blobs-Service-Working-with-Directori
There is a comment by @afr0 asking how to filter on folders..
There is two ways using the
GetDirectoryReference
or looping through a containers blobs and checking the type. The code below is in C#read this for more in depth coverage: http://www.codeproject.com/Articles/297052/Azure-Storage-Blobs-Service-Working-with-Directori
如果您使用 Microsoft Azure Storage Explorer,则有一个“新建文件夹”按钮,可让您在容器中创建文件夹。
这实际上是一个虚拟文件夹:
If you use Microsoft Azure Storage Explorer, there is a "New Folder" button that allows you to create a folder in a container.
This is actually a virtual folder:
您不需要创建
子目录
。只需创建blob 容器
并使用变量 filename 等文件名,如下代码所示:You do not need to create
sub directory
. Just createblob container
and use file name like the variable filename as below code:对于那些在动态目录中苦苦挣扎的人
根据版本 12,
您可以轻松地用反斜杠分隔目录或文件夹路径。
在这种情况下,它们将自动创建。
示例:
Azure 存储资源管理器中的结果视图
For someone struggling with dynamic directories
As per Version 12
You can easily have the directory or folder paths separated by a backslash.
They will be created automatically in this case.
Example:
The results views in Azure storage explorer
也想添加 UI 门户 方式来做。
如果您想创建文件夹结构,则必须使用每个文件的完整路径来完成。
您需要单击“上传 Blob”,展开“高级”并将其放置在“上传到文件夹”的路径中。
假设您有一个要上传的文件夹资产,该文件夹的内容如下所示下面
js 文件夹下有一个名为 main.js 的文件夹,则需要在上传到文件夹中输入路径“assets/js”。
现在必须对每个文件执行此操作。如果您有很多文件,建议您以编程方式执行此操作。
Wanted to add the UI portal Way to do as well.
In case you want to create the folder structure, you would have to do it with the complete path for each file.
You need to Click on Upload Blob, Expand the Advanced and put it the path saying "Upload to Folder"
So Lets say you have a folder assets you want to upload and the content of the folder look like below
And if you have a folder under js folder with name main.js, you need to type in the path "assets/js" in upload to folder.
Now This has to be done for each file. In case you have a lot of file, its recommended you do it programmatically.
正如@Egon 上面提到的,BLOB 存储中没有真正的文件夹管理。
您可以使用文件名中的“/”来实现文件系统的某些功能,但这有很多限制(例如,如果您需要重命名“文件夹”会发生什么?)。
作为一般规则,我会将文件尽可能平坦放在容器中,并让我的应用程序管理我想要向最终用户公开的任何结构(例如管理嵌套文件夹结构 >在我的数据库中,为每个文件都有一条记录,使用容器名和文件名引用 BLOB)。
As @Egon mentioned above, there is no real folder management in BLOB storage.
You can achieve some features of a file system using '/' in the file name, but this has many limitations (for example, what happen if you need to rename a "folder"?).
As a general rule, I would keep my files as flat as possible in a container, and have my application manage whatever structure I want to expose to the end users (for example manage a nested folder structure in my database, have a record for each file, referencing the BLOB using container-name and file-name).