相关疑难解决方法(0)

Google script replaceAllShapesWithImage with image from drive不再适用

从昨天开始,我的谷歌脚本之一不再起作用。剧本

  1. 在驱动器上拍照
  2. 复制幻灯片
  3. 用图像替换形状

但我收到了这个错误:

“提供的图片格式不受支持。”

-> 我授予对图像的所有访问权限:它不会改变任何内容

-> 如果我在驱动器外使用一个 url,脚本就可以工作

任何的想法

function test_image(){
  var imageUrls = DriveApp.getFilesByName("DSC_3632.png");
  var file = "undefined";
  while ( imageUrls.hasNext()) {
    var file = imageUrls.next();
  }

  var imageUrl = file.getDownloadUrl() + "&access_token=" + ScriptApp.getOAuthToken();

  var model_file = DriveApp.getFileById("your-id");
  var presentation = model_file.makeCopy("totot");
  var presentation =Slides.Presentations.get(presentation.getId())

  var requests = [{
      "replaceAllShapesWithImage":
        {
          "imageUrl": imageUrl,
          "imageReplaceMethod": "CENTER_INSIDE",
          "containsText": {
            "text": "toto",
            "matchCase": false,
          }
        }
    }];


  var presentationId = presentation.presentationId

  var createSlideResponse = Slides.Presentations.batchUpdate({
    requests: requests
  }, …
Run Code Online (Sandbox Code Playgroud)

google-apps-script google-drive-api google-slides google-slides-api

2
推荐指数
1
解决办法
1734
查看次数