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)
}
#> adding /home/runner/work/_temp/Library/gdalraster/extdata/ynp_fires_1984_2022.gpkg ...
#> 0...10...20...30...40...50...60...70...80...90...100 - done.
#> [1] "Files in zip archive:"
#> [1] "ynp_fires_1984_2022.gpkg"
#> [1] "SOZip metadata:"
#> $START_DATA_OFFSET
#> [1] "54"
#>
#> $COMPRESSION_METHOD
#> [1] "8 (DEFLATE)"
#>
#> $COMPRESSED_SIZE
#> [1] "164729"
#>
#> $UNCOMPRESSED_SIZE
#> [1] "307200"
#>
#> $SOZIP_FOUND
#> [1] "YES"
#>
#> $SOZIP_VERSION
#> [1] "1"
#>
#> $SOZIP_OFFSET_SIZE
#> [1] "8"
#>
#> $SOZIP_CHUNK_SIZE
#> [1] "32768"
#>
#> $SOZIP_START_DATA_OFFSET
#> [1] "164848"
#>
#> $SOZIP_VALID
#> [1] "YES"
#>
#> [1] 0