问题
How to create empty folder in azure blob storage just like empty folder in tool "Azure Explorer"
回答1:
Technically speaking, you can't have an empty folder in Azure Blob Storage as blob storage has a 2 level hierarchy - blob container and blob. You essentially create an illusion of a folder by prefixing the file name with the folder name you like e.g. assuming you want a style sheet (say site.css) in say css folder, you name the stylesheet file as css/site.css.
What some of the tools do is in order to create an empty folder, they create a zero byte blob and prefix it with the name of the folder and then don't show that zero byte blob. If you want, you can do that.
回答2:
Here's one way to do it with Linux.
az storage blob upload --container-name <container name> --name <folder name> -f /dev/null --account-name <storage account name>
- the file name ends with a trailing slash (e.g.
myfolder/) - the CLI expects a file, so just upload nothing (i.e.
/dev/null/)
回答3:
Gaurav's point is good to understand.
Though in practice, when using hdfs cli in bash, I've found you can't just rename the file (using mv as you normally would) if the sub-directory you're attempting to 'create' doesn't already exist.
You can however use hdfs dfs -mkdir -p wasb://container-name@account-name.blob.core.windows.net/sub-dir-name
Followed by hdfs dfs -mv wasb://container-name@account-name.blob.core.windows.net/file-name wasb://container-name@account-name.blob.core.windows.net/sub-dir-name/file-name
来源:https://stackoverflow.com/questions/26718243/how-to-create-empty-folder-in-azure-blob-storage