C#Drive v3:Teamdrive,获取文件的创建者

时间:2018-06-13 14:31:13

标签: google-drive-api

我正在尝试将文件的创建者添加到teamdrive中。 下面函数中的参数文件使用通配符填充了请求,因此所有字段都在文件上设置。

var postsRef = ref.child("posts");
var newPostRef = postsRef.push();
newPostRef
    .set({
        author: "gracehop",
        title: "Announcing COBOL, a New Programming Language"
    });

// we can also chain the two calls together
postsRef
    .push()
    .set({
        author: "alanisawesome",
        title: "The Turing Machine"
    });

问题在于行 private AddLinkedItemModel ConvertFileToAddLinkedItemModel(DriveService service, File file) { var metadata = new DriveFileMetadata(file.TeamDriveId, file.Id, file.WebViewLink); string owner = string.Empty; if(file.Permissions != null) { owner = file.Permissions.FirstOrDefault(f => f.Role.ToLowerInvariant() == "owner")?.DisplayName; } else if (file.PermissionIds != null) { var permissionRequest = service.Permissions.List(file.Id); if (file.TeamDriveId != null) { permissionRequest.SupportsTeamDrives = true; } permissionRequest.Fields = "*"; var permissionsList = permissionRequest.Execute(); owner = permissionsList.Permissions.FirstOrDefault(f => f.Role.ToLowerInvariant() == "owner")?.DisplayName; } return new AddLinkedItemModel { StorageName = Core.GoogleConstants.PluginName, Name = file.Name, Created = file.CreatedTime ?? DateTime.MinValue, Author = owner, Url = file.WebViewLink, Metadata = JsonConvert.SerializeObject(metadata, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) }; } 没有任何所有者,因为没有为teamdrive文件填充所有者角色? 如何让将文档上传到teamdrive的用户?

0 个答案:

没有答案