亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從 Azure 文件共享獲取文件元數據?

如何從 Azure 文件共享獲取文件元數據?

森林海 2023-02-24 10:35:36
我正在嘗試使用 npm storage-file-share從 Azure 文件共享獲取文件共享元數據。代碼片段如下,但沒有在文檔中找到任何獲取元數據的地方。有沒有辦法從 azure 庫中獲取元數據或者必須調用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     }
查看完整描述

2 回答

?
繁星淼淼

TA貢獻1775條經驗 獲得超11個贊

您可以將getProperties方法用于fetching metadata和file。directory下面是這個方法的定義:


返回文件的所有用戶定義元數據、標準 HTTP 屬性和系統屬性。它不返回文件的內容。


所以在你的代碼 -> 里面for await (const item of dirIter),你需要判斷是不是fileor directory,然后調用getProperties()方法。示例代碼如下所示:


for await (const item of dirIter) {

      if (item.kind === "directory") {

        

        const mydirectory = directoryClient.getDirectoryClient(item.name);

        var diretory_properties = await mydirectory.getProperties();


        //for test, you can print out the metadata

        console.log(diretory_properties.metadata);


        //here, you can write code to add the metadata in your list


      } else {

        

        const myfile=directoryClient.getFileClient(item.name);

        var the_properties = await myfile.getProperties();


        //for test, you can print out the metadata

        console.log(the_properties.metadata)


       //here, you can write code to add the metadata in your list


      }

    }


查看完整回答
反對 回復 2023-02-24
?
郎朗坤

TA貢獻1921條經驗 獲得超9個贊

您可以使用該方法getShareMetadata

fileService.getShareMetadata(shareName,?function?(error,?result,?response)?{


查看完整回答
反對 回復 2023-02-24
  • 2 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號