何时以天蓝色创建块状Blob? [英] When was a block blob created in azure?
问题描述
Blob引用包含一个Properties
属性,该属性的LastModified
为DateTimeOffset?
.但是,我找不到Blob的创建日期(时间).有没有我可以使用的标准API,或者我需要将其存储在meta中?
The blob reference contains a Properties
property that has a LastModified
of DateTimeOffset?
. However, I can't find when was the creation date(time) of the blob. Is there a standard API I can use or I need to store that in the meta?
public async Task<IBlobMeta> GetBlobMetaAsync(string blobId)
{
if (IsNullOrWhiteSpace(blobId))
throw new ArgumentException("Value cannot be null or whitespace.", nameof(blobId));
var blob = await EnsureGetBlobById(blobId);
await blob.FetchAttributesAsync();
string clientBlobName;
blob.Metadata.TryGetValue(BlobNameMetaKey, out clientBlobName);
var length = blob.Properties.Length;
var md5 = blob.Properties.ContentMD5;
var lastModified = blob.Properties.LastModified.Value.ToUniversalTime().DateTime;
var dateCreated= blob.Properties.???????;
return new AzureBlobMeta(blobId, clientBlobName, length, md5, dateCreated);
}
推荐答案
The Created
date property has been added in Storage Client Library, starting with version 9.2.0:
Blobs:添加了对Blob创建时间属性的支持.
Blobs: Added support for blob creation time property.
(自18年5月23日起在 Nuget 上提供)
(Available on Nuget since May 23 '18)
这是在 BlobProperties.cs :
/// <summary>
/// Gets the the creation time for the blob, expressed as a UTC value.
/// </summary>
/// <value>A <see cref="DateTimeOffset"/> containing the blob's creation time, in UTC format.</value>
public DateTimeOffset? Created { get; internal set; }
该类型是可空的DateTimeOffset,与LastModified
属性相同.
The type is nullable DateTimeOffset, same as LastModified
property.
值的来源来自REST API中的x-ms-creation-time
标头,该标头添加在
The source of the value comes from x-ms-creation-time
header in the REST API, which was added in version 2017-11-09:
x-ms-creation-time
2017-11-09版及更高版本.创建Blob的日期/时间.日期格式遵循RFC 1123.
x-ms-creation-time
Version 2017-11-09 and newer. The date/time at which the blob was created. The date format follows RFC 1123.
这篇关于何时以天蓝色创建块状Blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!