2016-05-27 35 views
0

从https://storage.cloud.google.com插入图片我在使用应用程序脚本在Google文档中插入图片时遇到问题。以格式

我所有的图像存储在https://storage.cloud.google.com与格式https://storage.cloud.google.com//100x120/86d932ad-b649-4c38-ADAF-ae0071ea3ecd

,我的代码是这样的:

/** * 插入用新的第参数 */ 功能createDocument(IDATA){

var doc = DocumentApp.getActiveDocument(); 
    var body = doc.getBody(); 

    // Access the body of the document, then add a paragraph. 
    // Retrieve an image from the web. 
    var resp = UrlFetchApp.fetch(iData[5]) 
    Logger.log(resp.getContentText()); 
    var celdas = [ 
    [iData[5], 'User: ' + iData[0]], 
    [, 'Name: ' + iData[1]], 
    [, 'U.O. : ' + iData[2]], 
    [, 'Email : ' + iData[3]], 
    [, 'Phone : ' + iData[4]] 
]; 

doc.getBody().appendTable(celdas); 
doc.getBody().appendImage(resp.getBlob()); 

}

信息存储在阵列iData中,并且不起作用。 成功创建表,但图像不会出现

回答

0

(一)你在你的图像路径两条斜线域后:

https://storage.cloud.google.com//100x120/86d932ad-b649-4c38-adaf-ae0071ea3ecd

应该有唯一的一个。

(b)确保这些图像可公开访问。在云端控制台中选中“公开分享”设置。

(c)确保这些文件具有正确的MIME类型集,例如, “image/jpeg” - 或者其他类型。由于文件URI不以“.jpg”结尾,浏览器可能无法正确解释它们。