File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
src/UmbracoFileSystemProviders.Azure Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -67,16 +67,19 @@ public override bool IsDirectory
67
67
public override Stream Open ( )
68
68
{
69
69
// Set the response headers here. It's a bit hacky.
70
- HttpCachePolicy cache = HttpContext . Current . Response . Cache ;
71
- cache . SetCacheability ( HttpCacheability . Public ) ;
72
- cache . VaryByHeaders [ "Accept-Encoding" ] = true ;
70
+ if ( HttpContext . Current != null )
71
+ {
72
+ HttpCachePolicy cache = HttpContext . Current . Response . Cache ;
73
+ cache . SetCacheability ( HttpCacheability . Public ) ;
74
+ cache . VaryByHeaders [ "Accept-Encoding" ] = true ;
73
75
74
- IFileSystem azureBlobFileSystem = FileSystemProviderManager . Current . GetUnderlyingFileSystemProvider ( "media" ) ;
75
- int maxDays = ( ( AzureBlobFileSystem ) azureBlobFileSystem ) . FileSystem . MaxDays ;
76
+ IFileSystem azureBlobFileSystem = FileSystemProviderManager . Current . GetUnderlyingFileSystemProvider ( "media" ) ;
77
+ int maxDays = ( ( AzureBlobFileSystem ) azureBlobFileSystem ) . FileSystem . MaxDays ;
76
78
77
- cache . SetExpires ( DateTime . Now . ToUniversalTime ( ) . AddDays ( maxDays ) ) ;
78
- cache . SetMaxAge ( new TimeSpan ( maxDays , 0 , 0 , 0 ) ) ;
79
- cache . SetRevalidation ( HttpCacheRevalidation . AllCaches ) ;
79
+ cache . SetExpires ( DateTime . Now . ToUniversalTime ( ) . AddDays ( maxDays ) ) ;
80
+ cache . SetMaxAge ( new TimeSpan ( maxDays , 0 , 0 , 0 ) ) ;
81
+ cache . SetRevalidation ( HttpCacheRevalidation . AllCaches ) ;
82
+ }
80
83
81
84
return this . stream ( ) ;
82
85
}
You can’t perform that action at this time.
0 commit comments