Skip to content

Commit 26e4aea

Browse files
author
nzdev
committed
Etag support
2 parents 7a76fcc + 9d95ba2 commit 26e4aea

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
@@ -705,6 +705,20 @@ public Stream OpenFile(string path)
705705
return null;
706706
}
707707

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

709723
private string _connectionString;
710724

0 commit comments

Comments
 (0)