dotnet-storage/OpenHarbor.Storage.Azure/Blob/AzureBlobFileInfo.cs

19 lines
912 B
C#

using Microsoft.WindowsAzure.Storage.Blob;
using OpenHarbor.Storage.Abstractions;
namespace OpenHarbor.Storage.Azure.Blob;
public class AzureBlobFileInfo(CloudBlockBlob fileBlock) : IFileInfo
{
public string FileName => System.IO.Path.GetFileName(fileBlock.Name);
public string Extension => System.IO.Path.GetExtension(fileBlock.Name);
public long FileSize => fileBlock.Properties.Length;
public DateTimeOffset? CreatedTime => fileBlock.Properties.Created;
public DateTimeOffset? LastModifiedTime => fileBlock.Properties.LastModified;
public DateTimeOffset? LastAccessTime => null;
public DateTime? CreatedTimeUtc => CreatedTime?.UtcDateTime;
public DateTime? LastModifiedTimeUtc => LastModifiedTime?.UtcDateTime;
public DateTime? LastAccessTimeUtc => null;
public string Path => fileBlock.Uri.LocalPath.Replace($"/{fileBlock.Container.Name}/", "");
public bool IsDirectory => false;
}