GroupDocs.Metadata for Java can load a document straight from a web resource. Pass a java.net.URI to the Metadata constructor, and you don’t have to download the file yourself.
The document is downloaded into memory and then loaded the same way as a document loaded from a stream.
Loading a document from a URI
The following code sample shows how to load an image from a URL and read its EXIF properties.
advanced_usage.loading_files.LoadFromUri
// The document is downloaded into memory and then loaded like a stream
URIuri=URI.create("https://raw.githubusercontent.com/groupdocs-metadata/GroupDocs.Metadata-for-Java/master/Examples/Resources/SampleFiles/Input/exif.jpg");try(Metadatametadata=newMetadata(uri)){JpegRootPackageroot=metadata.getRootPackageGeneric();System.out.println(root.getFileType().getFileFormat());if(root.getExifPackage()!=null){System.out.println(root.getExifPackage().getMake());System.out.println(root.getExifPackage().getModel());}}
Loading a document of a specific format from a URI
Use the Metadata(URI, LoadOptions) constructor to set the file format explicitly or to pass a password.
RAR, 7z, TAR, AAR, GZIP, BZ2, XZ and Zstandard archives are recognized by the file extension, and a URI does not give the library a file name. Set the format of such an archive explicitly, otherwise the archive is not recognized correctly (a RAR archive, for example, is detected as an MP3 file).
The whole document is downloaded into memory before it is processed. For large files, consider downloading them to a local disk first and loading them from the path.
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: