vsi_get_file_metadata()
returns metadata for file system objects.
Implemented for network-like filesystems. Starting with GDAL 3.7,
implemented for /vsizip/ with SOZip metadata.
Wrapper of VSIGetFileMetadata()
in the GDAL Common Portability Library.
Details
The metadata available depends on the file system. The following are supported as of GDAL 3.9:
HEADERS: to get HTTP headers for network-like filesystems (/vsicurl/, /vsis3/, /vsgis/, etc).
TAGS: for /vsis3/, to get S3 Object tagging information. For /vsiaz/, to get blob tags.
STATUS: specific to /vsiadls/: returns all system-defined properties for a path (seems in practice to be a subset of HEADERS).
ACL: specific to /vsiadls/ and /vsigs/: returns the access control list for a path. For /vsigs/, a single
XML=xml_content
string is returned.METADATA: specific to /vsiaz/: blob metadata (this will be a subset of what
domain=HEADERS
returns).ZIP: specific to /vsizip/: to obtain ZIP specific metadata, in particular if a file is SOZIP-enabled (
SOZIP_VALID=YES
).
Examples
# create an SOZip-enabled file and validate
# Requires GDAL >= 3.7
f <- system.file("extdata/ynp_fires_1984_2022.gpkg", package="gdalraster")
if (as.integer(gdal_version()[2]) >= 3070000) {
zip_file <- tempfile(fileext=".zip")
addFilesInZip(zip_file, f, full_paths=FALSE, sozip_enabled="YES")
zip_vsi <- file.path("/vsizip", zip_file)
print("Files in zip archive:")
print(vsi_read_dir(zip_vsi))
print("SOZip metadata:")
print(vsi_get_file_metadata(zip_vsi, domain="ZIP"))
vsi_unlink(zip_file)
}