This example demonstrates how to load a file from a binary stream. Pass any readable binary file-like object (an open(..., "rb") handle or an io.BytesIO) to the Metadata constructor.
fromgroupdocs.metadataimportMetadatadefload_from_stream():withopen("input.docx","rb")asstream:withMetadata(stream)asmetadata:# Extract, edit or remove metadata hereprint(f"Loaded {metadata.file_format} from a stream")if__name__=="__main__":load_from_stream()
input.docx is the sample file used in this example. Click here to download it.