API以及“禁止下载,打印和复制任何Google云端硬盘文件'

时间:2015-09-03 23:59:05

标签: google-drive-api

谷歌几个月前发布了此功能。以下链接提到可以通过API访问它。尝试使用驱动器api补丁调用切换"禁用下载.."我假设的旗帜是"可复制的"国旗,但无济于事。

https://connect.googleforwork.com/docs/DOC-11088

感谢任何帮助,谢谢。

2 个答案:

答案 0 :(得分:0)

您正在寻找“labels.restricted”属性。

以下是您在C#中所做的事情。


    Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
    body.Title = Path.GetFileName(filename);
    body.Labels = new Google.Apis.Drive.v2.Data.File.LabelsData();

    body.Labels.Restricted = true;

    byte[] byteArray = System.IO.File.ReadAllBytes(filename);
    MemoryStream stream = new MemoryStream(byteArray);
    try
    {
            FilesResource.InsertMediaUpload request = 
                 service.Files.Insert(body, stream, mimeType);
            request.Upload();
    }
    catch(Exception ex){
       ExceptionLogger.log(ex);
    }

请查看以下链接以获取样品。 https://developers.google.com/drive/v2/reference/files/copy

答案 1 :(得分:0)

labels.restricted已过时。 您应该改为设置copyRequiresWriterPermission元数据属性。

来源:Google Drive API Files Reference