简体   繁体   English

Autodesk Forge 下载 object,但无法判断它是 Revit model 还是 zip 文件

[英]Autodesk Forge download object, but cannot tell if it is a Revit model or zip file

I was downloading Revit models from BIM360 team hub via ForgeAPI using the following uri.我正在使用以下 uri 通过 ForgeAPI 从 BIM360 团队中心下载 Revit 模型。

https://developer.api.autodesk.com/oss/v2/buckets/:bucketKey/objects/:objectName

All my objectName ended with .rvt .我所有的.rvt objectName So I downloaded and saved them as rvt file.所以我下载并保存为rvt文件。 However I noticed that some of the files cannot be opened by Revit.但是我注意到 Revit 无法打开某些文件。 They are actually not rvt files but zip files.它们实际上不是rvt文件,而是 zip 文件。 So I have to change the extension to .zip and unzip the file to get real 'rvt` files.所以我必须将扩展名更改为.zip并解压缩文件以获得真正的“rvt”文件。

My Problem is that not all files is zip file.我的问题是并非所有文件都是zip文件。 I cannot tell from the API because the URI I request is always ended with .rvt .我无法从 API 中分辨出来,因为我请求的 URI 总是以.rvt

Every Unix OS provides the file command, a standard utility program for recognising the type of data contained in a computer file:每个 Unix 操作系统都提供file命令,这是一个标准实用程序,用于识别计算机文件中包含的数据类型:

https://en.wikipedia.org/wiki/File_(command) https://en.wikipedia.org/wiki/File_(命令)

A zip file is directly recognised and reported like this: zip文件被直接识别并报告如下:

$ file test_dataset.zip
test_dataset.zip: Zip archive data, at least v2.0 to extract

A Revit RVT model is a Windows compound document file, so it generates the following output: Revit RVT model 是 Windows 复合文档文件,因此它生成以下 output:

$ file little_house_2021.rvt
little_house_2021.rvt: Composite Document File V2 Document, Cannot read section info

Hence you can use the same algorithm as file does to distinguish between RVT and ZIP files.因此,您可以使用与file相同的算法来区分 RVT 和 ZIP 文件。

Afaik, file just looks at the first couple of bytes in the given file. Afaik, file只查看给定文件中的前几个字节。

The Python programming language offers similar utilities; Python 编程语言提供了类似的实用程序; try an Internet search for distinguish file type python ;尝试在 Internet 上搜索区分文件类型 python the first hits explain How to check type of files without extensions in Python and point to the filetype Python project .第一次点击解释了如何检查 Python 中没有扩展名的文件类型,并指向filetype项目

Other programming languages can provide similar functionality.其他编程语言可以提供类似的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM