Revit 4 worksharing, publishes a file to BIM360.
This file is named as a .rvt file (ie. 'mybigrevitproject.rvt'), but in fact, it's really a zip file in disguise. If you rename it to zip, download it, and unzip it, you'll find lots of .RVT inside the zip.
There's a neat trick to figuring this out, without downloading the entire file.
Use a range GET on the first 16 bytes, and check for the magic header.
For full details, check out this repo: https://github.com/wallabyway
Here's a snippet of the code that will help:
https://github.com/wallabyway/bim360-zip-extract/blob/master/server.js#L167
UPDATE:
I meant to say this repo: https://github.com/wallabyway/bim360-zip-extract
You can find the magic header signature, based on this pkzip info here: https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html
The signature of the local file header. This is always '\x50\x4b\x03\x04'.
The code for the range get is:
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;
}