我有一个脚本,可以从第 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)
希望能帮助解决这个问题。