@@ -1335,6 +1335,49 @@ Returns the size of the blob corresponding to `object::AzObject`
13351335"""
13361336Base. filesize (o:: AzObject ) = filesize (o. container, o. name)
13371337
1338+ """
1339+ metadata(container, "blobname")
1340+
1341+ Returns a dictionary corresponding to the metadata of the blob "blobname" in `container::AzContainer`. The dictionary contains the following keys:
1342+
1343+ * "size": The size of the blob in bytes.
1344+ * "modified": The last modified date of the blob.
1345+ * "created": The creation date of the blob.
1346+ * "accessed": The last access date of the blob.
1347+ """
1348+ function metadata (c:: AzContainer , o:: AbstractString )
1349+ r = @retry c. nretry HTTP. request (
1350+ " HEAD" ,
1351+ " https://$(c. storageaccount) .blob.core.windows.net/$(c. containername) /$(addprefix (c,o)) " ,
1352+ [
1353+ " Authorization" => " Bearer $(token (c. session)) " ,
1354+ " x-ms-version" => API_VERSION
1355+ ],
1356+ retry = false ,
1357+ verbose = c. verbose,
1358+ connect_timeout = c. connect_timeout,
1359+ readtimeout = c. read_timeout)
1360+
1361+ Dict (
1362+ " size" => parse (Int, HTTP. header (r, " Content-Length" , " 0" )),
1363+ " modified" => tryparse (DateTime, HTTP. header (r, " Last-Modified" , " not a date" ), dateformat " e, dd u yyyy HH:MM:SS \G\M\T " ),
1364+ " created" => tryparse (DateTime, HTTP. header (r, " x-ms-creation-time" , " not a date" ), dateformat " e, dd u yyyy HH:MM:SS \G\M\T " ),
1365+ " accessed" => tryparse (DateTime, HTTP. header (r, " x-ms-last-access-time" , " not a date" ), dateformat " e, dd u yyyy HH:MM:SS \G\M\T " )
1366+ )
1367+ end
1368+
1369+ """
1370+ metadata(object::AzObject)
1371+
1372+ Returns a dictionary corresponding to the metadata of the blob corresponding to `object::AzObject`. The dictionary contains the following keys:
1373+
1374+ * "size": The size of the blob in bytes.
1375+ * "modified": The last modified date of the blob.
1376+ * "created": The creation date of the blob.
1377+ * "accessed": The last access date of the blob.
1378+ """
1379+ metadata (o:: AzObject ) = metadata (o. container, o. name)
1380+
13381381"""
13391382 rm(container, "blobname")
13401383
@@ -1540,6 +1583,6 @@ Returns the access tier for a blob `o::AzObject`.
15401583"""
15411584tier (o:: AzObject ) = tier (o. container, o. name)
15421585
1543- export AzContainer, containers, readdlm, status, tier, tier!, writedlm
1586+ export AzContainer, containers, metadata, readdlm, status, tier, tier!, writedlm
15441587
15451588end
0 commit comments