I'm trying to get File Share Metadata from Azure file share using npm storage-file-share.
Code snippet as below, but didn't find anything in documentation where to get metadata.
Is there any way to get metadata from azure library or has to call rest api?
const serviceClient = new ShareServiceClient(
`https://${storageAccountName}.file.core.windows.net`,
credential
);
const directoryClient = serviceClient.getShareClient(shareName).getDirectoryClient(directoryPath);
const dirIter = directoryClient.listFilesAndDirectories();
const list = [];
for await (const item of dirIter) {
list.push({name: item.name, metadata????}); // Need item metadata
}
You can use the getProperties method for
fetching metadata
for thefile
anddirectory
. Here is the definition of this method:So in your code -> inside
for await (const item of dirIter)
, you need to determine if it's afile
ordirectory
, then call thegetProperties()
method. The sample code looks like below: