我有一个脚本,可以从第 3 方 API 接收 gzipped blob。我正在尝试使用它来解压缩它Utilities.ungzip(),但收到无效参数错误。这是示例代码:
var liveReportResponse = UrlFetchApp.fetch(url)
var unzipped = Utilities.ungzip(liveReportResponse.getBlob()) // Fails with Invalid Argument error
Run Code Online (Sandbox Code Playgroud)
奇怪的是,我可以使用驱动器文件作为中间存储来提取内容:
var image = liveReportResponse.getBlob()
var file = {
title: 'some_file_.gzip'
};
file = Drive.Files.insert(file, image);
var file = DriveApp.getFileById(file.id)
var blob = file.getBlob()
var someBytes = Utilities.ungzip(blob) // It works
var data = someBytes.getDataAsString()
Run Code Online (Sandbox Code Playgroud)
希望能帮助解决这个问题。
我在代理后面工作,所以我需要配置我的连接。它适用于定义选项列表和调用 getURL:
opts <- list(
proxy = "http://****",
proxyusername = "****",
proxypassword = "*****",
proxyport = ****
)
getURL("http://stackoverflow.com", .opts = opts)
Run Code Online (Sandbox Code Playgroud)
我想将此选项设置为默认值,但仍然找不到任何可行的解决方案。你有什么建议吗?
谢谢你。