Autodesk Forge 下载对象,但无法判断它是 Revit 模型还是 zip 文件
Autodesk Forge download object, but cannot tell if it is a Revit model or zip file
我正在使用以下 uri 通过 ForgeAPI 从 BIM360 团队中心下载 Revit 模型。
https://developer.api.autodesk.com/oss/v2/buckets/:bucketKey/objects/:objectName
我所有的 objectName
都以 .rvt
结尾。所以我下载并将它们保存为 rvt
文件。
但是我注意到 Revit 无法打开某些文件。它们实际上不是 rvt
文件,而是 zip 文件。所以我必须将扩展名更改为 .zip
并解压缩文件以获得真正的“rvt”文件。
我的问题是并非所有文件都是 zip
文件。我无法从 API 中分辨出来,因为我请求的 URI 总是以 .rvt
.
结尾
每个 Unix OS 都提供 file
命令,这是一个标准的实用程序,用于识别计算机文件中包含的数据类型:
https://en.wikipedia.org/wiki/File_(command)
一个zip
文件直接识别报错是这样的:
$ file test_dataset.zip
test_dataset.zip: Zip archive data, at least v2.0 to extract
Revit RVT 模型是一个 Windows 复合文档文件,因此它生成以下输出:
$ file little_house_2021.rvt
little_house_2021.rvt: Composite Document File V2 Document, Cannot read section info
因此您可以使用与 file
相同的算法来区分 RVT 和 ZIP 文件。
Afaik,file
只查看给定文件中的前几个字节。
Python 编程语言提供了类似的实用程序;尝试互联网搜索
对于 distinguish file type python;第一击解释
How to check type of files without extensions in Python
并指向 filetype
Python project.
其他编程语言可以提供类似的功能。
我正在使用以下 uri 通过 ForgeAPI 从 BIM360 团队中心下载 Revit 模型。
https://developer.api.autodesk.com/oss/v2/buckets/:bucketKey/objects/:objectName
我所有的 objectName
都以 .rvt
结尾。所以我下载并将它们保存为 rvt
文件。
但是我注意到 Revit 无法打开某些文件。它们实际上不是 rvt
文件,而是 zip 文件。所以我必须将扩展名更改为 .zip
并解压缩文件以获得真正的“rvt”文件。
我的问题是并非所有文件都是 zip
文件。我无法从 API 中分辨出来,因为我请求的 URI 总是以 .rvt
.
每个 Unix OS 都提供 file
命令,这是一个标准的实用程序,用于识别计算机文件中包含的数据类型:
https://en.wikipedia.org/wiki/File_(command)
一个zip
文件直接识别报错是这样的:
$ file test_dataset.zip
test_dataset.zip: Zip archive data, at least v2.0 to extract
Revit RVT 模型是一个 Windows 复合文档文件,因此它生成以下输出:
$ file little_house_2021.rvt
little_house_2021.rvt: Composite Document File V2 Document, Cannot read section info
因此您可以使用与 file
相同的算法来区分 RVT 和 ZIP 文件。
Afaik,file
只查看给定文件中的前几个字节。
Python 编程语言提供了类似的实用程序;尝试互联网搜索
对于 distinguish file type python;第一击解释
How to check type of files without extensions in Python
并指向 filetype
Python project.
其他编程语言可以提供类似的功能。