伪造数据管理返回压缩文件 [英] Forge Data management returns zip file
本文介绍了伪造数据管理返回压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我获得云中获取的Revit Model的下载链接时,如here所示。我发现该链接有时会返回一个Revit文件,有时会返回一个压缩文件。我将此URL传递给Design Automation,因此它有时会失败(以防链接下载一个压缩文件)。当item.data.attributes.displayName
在两种情况下都返回*.rvt时,我如何区分这两个项目。在所有情况下,应如何获取RVT文件?
此question讨论了相同的问题,但没有解决方案(这是2年前的问题,希望有什么变化)。
推荐答案
Revit4工作共享将文件发布到BIM360.
此文件命名为.rvt文件(即‘mybigrevite.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 'x50x4bx03x04'.
Range 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) === x50x4bx03x04) {
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;
}
这篇关于伪造数据管理返回压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文