Menu

Can't open ifc file like a bytes object

Help
2022-04-18
2022-04-22
  • Alexander Nabiev

    Hi everyone!
    I need to open IFC file from minio S3 storage like a bytes object
    Ifc file is stored in minio S3 storage. I can read it with minio module and i get file in "bytes type" (see below)

    ifcfile = minioClient.get_object('nabievtest', 'OPU.ifc')
    print(type(ifcfile.read()))

    <class 'bytes'=""></class>

    The file itself is correct, I check it with traditional way of open
    But I can't read it this way from storage:

    ifc_file = ifcopenshell.open(ifcfile.read())

    TypeError: in method 'open', argument 1 of type 'std::string const &'

    Can you explain me what i doing wrong?

     
    • Thomas Krijnen

      Thomas Krijnen - 2022-04-22

      open() expects the filename on disk as a python str not bytes.

      If you have file content there is ifcopenshell.file.from_string() but it also expects a string so use ifcopenshell.file.from_string(ifcfile.read().decode('ascii'))

       
      • Alexander Nabiev

        It works, thanks!

         

Log in to post a comment.