Load from a stream

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.

from groupdocs.metadata import Metadata


def load_from_stream():
    with open("input.docx", "rb") as stream:
        with Metadata(stream) as metadata:
            # Extract, edit or remove metadata here
            print(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.

Loaded 3 from a stream

Download full output

See also

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document metadata management App

You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.