我经常下载一个Mimetype“ application / x-zip”的.zip文件(不是我创建的),该文件未由Utilities.unzip(file)处理,出现以下错误。我希望有人能够帮助我解析此文件。
谢谢。
var thisFile = DriveApp.getFileById(newestFileId);
//Successfully gets the file as verified by other processes
var thisBlob = thisFile.getBlob();
var createMe = thisFolder.createFile("workingb.zip", thisBlob, "application/zip");
//Creates a 4-byte file with the text "Blob"
var createMe = thisFolder.createFile("workingf.zip", thisFile, "application/zip");
//Creates an 11-byte file with the text the same as the filename.ext
Logger.log(thisFile.getMimeType());
// "application/x-zip"
var test1 = thisFile.getAs("application/zip");
//Exception: Converting from application/x-zip to application/zip is not supported
var thisUnzip = Utilities.unzip(test1);
//Exception: Invalid argument
答案 0 :(得分:0)
此修改如何?我认为您的情况有两种模式。
如果文件名的扩展名为.zip
,该修改如何?
var thisFile = DriveApp.getFileById(newestFileId);
var thisBlob = thisFile.getBlob();
var convertedBlob = thisBlob.setContentTypeFromExtension();
var thisUnzip = Utilities.unzip(convertedBlob);
如果文件名没有扩展名,或者扩展名是.zip
以外的值,那么该修改如何?
var thisFile = DriveApp.getFileById(newestFileId);
var thisBlob = thisFile.getBlob();
var convertedBlob = thisBlob.setContentType("application/zip");
var thisUnzip = Utilities.unzip(convertedBlob);
如果这些不是您想要的,对不起。