detect method

detect(, file_name)

Detect the file format from file name, file must be readable so Aspose.3D can detect the file format through file header.

Returns

The FileFormat instance of the detected type or null if failed.


@staticmethod
def detect(file_name):
    ...
ParameterTypeDescription
file_namestrPath to the file to detect file format.

Exceptions

ExceptionDescription
IOExceptionException thrown when failed to read data.

Example

from aspose.threed import FileFormat

fmt = FileFormat.detect("input.fbx")
print(f"Input file format: {fmt}")

detect(, stream, file_name)

Detect the file format from data stream, file name is optional for guessing types that has no magic header.

Returns

The FileFormat instance of the detected type or null if failed.


@staticmethod
def detect(stream, file_name):
    ...
ParameterTypeDescription
streamio.RawIOBaseStream containing data to detect
file_namestrOriginal file name of the data, used as hint.

Exceptions

ExceptionDescription
IOExceptionException thrown when failed to read data.

Example

from aspose.threed import FileFormat
from io import BytesIO
import bytearray

bytes = bytearray(100)
fmt = FileFormat.detect(BytesIO(bytes), "input-file")
print(f"Input data format: {fmt}")

See Also