首页 > 解决方案 > 是否可以在 google drive api v3 C# 中为文件添加自定义元数据?

问题描述

我有一个要上传到 Google Drive 的文件列表。

是否可以向每个文件添加自定义元数据?

标签: c#google-drive-api

解决方案


是的,这是可能的。

请参阅:https ://developers.google.com/drive/api/v3/properties

您可以在对象上设置properties和。appPropertiesFile

“要添加对所有应用程序可见的属性,请使用资源properties字段files。要添加仅限于您的应用程序的属性,请使用资源appProperties字段files。”

示例(假设您知道如何使用 contenttype 上传文件流,并且只想对元数据进行解释):

var file = new File
{
    Properties = new Dictionary<string, string>
    {
        { "CustomTag", "1234" }
    }
};
service.Files.Create(file, fileStream, contentType).Execute();

推荐阅读