@@ -9,14 +9,18 @@ namespace Our.Umbraco.FileSystemProviders.Azure
99 using System . IO ;
1010 using System . Web ;
1111 using System . Web . Hosting ;
12- using global ::Umbraco . Core . Composing ;
1312 using global ::Umbraco . Core . IO ;
1413
1514 /// <summary>
1615 /// Represents a file object in a virtual file.
1716 /// </summary>
1817 internal class FileSystemVirtualFile : VirtualFile
1918 {
19+ /// <summary>
20+ /// The file system.
21+ /// </summary>
22+ private readonly IFileSystem fileSystem ;
23+
2024 /// <summary>
2125 /// The stream function delegate.
2226 /// </summary>
@@ -40,7 +44,9 @@ public FileSystemVirtualFile(string virtualPath, Lazy<IFileSystem> fileSystem, s
4044 throw new ArgumentNullException ( nameof ( fileSystem ) ) ;
4145 }
4246
43- this . stream = ( ) => fileSystem . Value . OpenFile ( fileSystemPath ) ;
47+ this . fileSystem = fileSystem . Value ;
48+
49+ this . stream = ( ) => this . fileSystem . OpenFile ( fileSystemPath ) ;
4450 }
4551
4652 /// <summary>
@@ -69,14 +75,19 @@ public override Stream Open()
6975 // Add Accept-Ranges header to fix videos not playing on Safari
7076 HttpContext . Current . Response . AppendHeader ( "Accept-Ranges" , "bytes" ) ;
7177
72- IFileSystem azureBlobFileSystem = Current . MediaFileSystem . Unwrap ( ) ;
73- int maxDays = ( ( AzureBlobFileSystem ) azureBlobFileSystem ) . FileSystem . MaxDays ;
78+ var unwrappedFileSystem = this . fileSystem . Unwrap ( ) ;
79+ if ( ! ( unwrappedFileSystem is AzureFileSystem azureFileSystem ) )
80+ {
81+ azureFileSystem = ( ( AzureBlobFileSystem ) this . fileSystem ) . FileSystem ;
82+ }
7483
84+ int maxDays = azureFileSystem . MaxDays ;
7585 cache . SetExpires ( DateTime . Now . ToUniversalTime ( ) . AddDays ( maxDays ) ) ;
7686 cache . SetMaxAge ( new TimeSpan ( maxDays , 0 , 0 , 0 ) ) ;
7787 cache . SetRevalidation ( HttpCacheRevalidation . AllCaches ) ;
78- cache . SetLastModified ( azureBlobFileSystem . GetLastModified ( VirtualPath ) . DateTime ) ;
79- var etag = ( ( AzureBlobFileSystem ) azureBlobFileSystem ) . FileSystem . GetETag ( VirtualPath ) ;
88+ cache . SetLastModified ( azureFileSystem . GetLastModified ( VirtualPath ) . DateTime ) ;
89+
90+ var etag = azureFileSystem . GetETag ( VirtualPath ) ;
8091 if ( ! string . IsNullOrWhiteSpace ( etag ) )
8192 {
8293 cache . SetETag ( etag ) ;
0 commit comments