【问题标题】:Get the ACL of a folder with only the URL using Google Docs API使用 Google Docs API 获取仅包含 URL 的文件夹的 ACL
【发布时间】:2012-05-12 02:26:10
【问题描述】:

我正在使用 Google Data .NET 库。给定包含文件夹 ID 的文件夹的 URL(例如,用户可能从浏览器复制和粘贴),我希望能够获取该文件夹的访问控制列表并进行更改。

我可以像这样使用 FolderQuery:

        DocumentsService ss = new DocumentsService(appname);
        ss.setUserCredentials(username, password);

        FolderQuery fq = new FolderQuery(folderid);
        DocumentsFeed df = ss.Query(fq);

        DocumentEntry de = (DocumentEntry)df.Entries[0];
        Uri AclUri = new Uri(de.AccessControlList);

但这只会返回文件夹的内容。我想要文件夹本身。

有什么建议吗?

谢谢!

【问题讨论】:

    标签: .net google-api gdata


    【解决方案1】:

    FolderQuery 类用于检索文件夹的内容,但您可以像检索文档一样检索文件夹的访问控制列表。

    以下 sn-p 假定 folderId 是您要为其检索 ACL 的文件夹的 ID:

    DocumentsService ss = new DocumentsService(appname);
    ss.setUserCredentials(username, password);
    
    string uri = String.Format(DocumentsListQuery.aclsUriTemplate, folderId);
    AclQuery query = new AclQuery(uri);
    AclFeed feed = ss.Query(query);
    
    foreach (AclEntry acl in feed.Entries)
    {
        // Print the acl Role to the screen
        Console.WriteLine(acl.Role.Value);
        // Print the acl Scope type and value to the screen
        Console.WriteLine(acl.Scope.Type + " - " + acl.Scope.Value);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多