简体   繁体   English

在 js 中设置 azure blob 的元数据

[英]Setting Metadata on azure blob in js

I see examples for c#, but I cannot find implement info for js.我看到 c# 的示例,但找不到 js 的实现信息。 How do I set metadata for blob in js?如何在 js 中为 blob 设置元数据?

const metadata = {name, selection}

await blockBlobClient.upload(file);
await blockBlobClient.setMetadata(container, file, metadata)

I am looking at this link and it calls setMetadata but it doesn't set:我正在查看此链接,它调用setMetadata但未设置:

http://azure.github.io/azure-storage-node/BlobService.html#setBlobMetadata__anchor http://azure.github.io/azure-storage-node/BlobService.html#setBlobMetadata__anchor

Thank you @gaurav mantri for your suggestion..谢谢@gaurav mantri的建议..

Converting your suggestion as answer to help reach other community members.将您的建议转化为答案以帮助接触其他社区成员。

solution by @gaurav mantri: @gaurav mantri 的解决方案

To set metadata for blob in js,you may use要在 js 中为 blob 设置元数据,您可以使用

setMetadata(metadata?: Metadata, options?: BlobSetMetadataOptions) when using new azure-storage SDK (azure sdk for java script) as the old azure-storage SDK is deprecated. setMetadata(metadata?: Metadata, options?: BlobSetMetadataOptions)当使用新的 azure-storage SDK(azure sdk 用于 java 脚本)时,旧的 azure-storage SDK 已弃用。

Please Refer these for the same:请参考这些:

BlockBlobClient class | 块BlobClient class | Microsoft Docs 微软文档

BlobSetMetadataOptions interface | BlobSetMetadataOptions 界面 | Microsoft Docs 微软文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM