发布于 2022-02-03 21:57:20
修改4工作共享,将文件发布到BIM360。
这个文件被命名为.rvt文件(即。( 'mybigrevitproject.rvt'),但实际上,它实际上是一个伪装的压缩文件。如果您将其重命名为zip、下载并解压缩,您将在zip中找到许多.RVT。
在不下载整个文件的情况下,解决这个问题有一个巧妙的技巧。
在前16个字节上使用范围GET,并检查魔术标题。
有关详细信息,请参阅下面的回购:https://github.com/wallabyway
下面是帮助您的代码片段:https://github.com/wallabyway/bim360-zip-extract/blob/master/server.js#L167
更新:我想说的是回购:https://github.com/wallabyway/bim360-zip-extract
您可以根据以下pkzip信息找到神奇的头签名:https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html
The signature of the local file header. This is always '\x50\x4b\x03\x04'.范围get的代码是:
const chunksize = 16 * 1024; // only need 16k bytes of data
const buffSignature = await this._fetchWrite(0, chunksize); // fetch/write header
// something like this...
if (buffSignature.slice(0,3) === \x50\x4b\x03\x04) {
console.log("this is a zip file, not a Revit file...");
}
async _fetchWrite( offset, length ) {
const res = await fetch( this.URL, { headers: {
'range': `bytes=${offset}-${offset+length}`,
'Authorization': `Bearer ${this.token}`
}});
if (res.status != 206)
throw(`error:${res.statusText}, bytes=${offset}-${offset+length}`)
const buff = await res.buffer();
return buff;
}https://stackoverflow.com/questions/70978535
复制相似问题