Skip to content

Commit 9d95ba2

Browse files
author
nzdev
committed
etag support
1 parent aed3b77 commit 9d95ba2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/UmbracoFileSystemProviders.Azure.Media/FileSystemVirtualFile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public override Stream Open()
7575
cache.SetExpires(DateTime.Now.ToUniversalTime().AddDays(maxDays));
7676
cache.SetMaxAge(new TimeSpan(maxDays, 0, 0, 0));
7777
cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
78+
cache.SetLastModified(azureBlobFileSystem.GetLastModified(VirtualPath).DateTime);
79+
var etag = ((AzureBlobFileSystem)azureBlobFileSystem).FileSystem.GetETag(VirtualPath);
80+
if (!string.IsNullOrWhiteSpace(etag))
81+
{
82+
cache.SetETag(etag);
83+
}
7884
}
7985

8086
return this.stream();

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,20 @@ public Stream OpenFile(string path)
704704
return null;
705705
}
706706

707+
public string GetETag(string path,string format = "G")
708+
{
709+
Current.Logger.Debug<AzureBlobFileSystem>($"GetSize(path) method executed with path:{path}");
710+
711+
var blockBlob = this.GetBlockBlobReference(path);
712+
713+
if (blockBlob != null)
714+
{
715+
var properties = blockBlob.GetProperties().Value;
716+
return properties.ETag.ToString(format);
717+
}
718+
719+
return null;
720+
}
707721

708722
private string _connectionString;
709723

0 commit comments

Comments
 (0)