[英]Azure Blob Storage Java SDK 12 extract file name from blob name
let's say I have blob structure like this:假设我有这样的 blob 结构:
dir0<\/code>
├── dir1<\/code>
│ ├── file11<\/code>
│ └── file12<\/code>
├── dir2<\/code>
└── dir3<\/code>
After listing the
dir1<\/code> that contains two files
file11<\/code> ,
file12<\/code> with
listBlobsByHierarchy("dir0\/dir1\/")<\/code> method I'm getting two blobs with
blobName<\/code> property set to
dir0\/dir1\/file11<\/code> and
dir0\/dir1\/file12<\/code> , so
<virtual_path><\/code> \/
<file_name><\/code> .
在使用 listBlobsByHierarchy("
file12<\/code>
listBlobsByHierarchy("dir0\/dir1\/")<\/code>方法列出包含两个文件
file11<\/code>和 file12 的
dir1<\/code>之后,我得到两个
blobName<\/code>属性设置为
dir0\/dir1\/file11<\/code>
dir0\/dir1\/file12<\/code>的 blob,所以
<virtual_path><\/code> \/
<file_name><\/code> 。
That's OK, but in some point I need to get the
<file_name><\/code> part.
没关系,但在某些时候我需要获取
<file_name><\/code>部分。
My question is: Does Azure Storage SDK 12 for Java provides a mechanism for obtaining
<file_name><\/code> part from blob name?<\/strong>
我的问题是:适用于 Java 的 Azure Storage SDK 12 是否提供了一种从 blob 名称中获取
<file_name><\/code>部分的机制?<\/strong>
I could do it myself but it's hard to believe that SDK doesn't provide this functionality... Maybe you guys know different elegant way to do so?
我可以自己做,但很难相信 SDK 不提供这个功能......也许你们知道不同的优雅方式来做到这一点? How do you usually handle such things?
你通常如何处理这样的事情?
It's a bit weird to me that SDK seems not to support building prefixes or getting file names from blob names :PI expected sth like
fileName<\/code> field in
BlobItem<\/code> class or
buildPrefix(List<String> segments)<\/code> method for joining path segments with '\/'.
对我来说有点奇怪的是,SDK 似乎不支持构建前缀或从 blob 名称获取文件名:PI 预期的东西,例如
BlobItem<\/code>类中的
fileName<\/code>字段或用于使用“\/”连接路径段的
buildPrefix(List<String> segments)<\/code>方法。
"
You just do:你只需这样做:
blobName.replaceFirst("^/dir0/dir1/", "")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.