@@ -18,34 +18,51 @@ namespace Umbraco.StorageProviders.AzureBlob.IO
18
18
/// <inheritdoc />
19
19
public class AzureBlobFileSystem : IAzureBlobFileSystem , IFileProviderFactory
20
20
{
21
- private readonly BlobContainerClient _container ;
22
- private readonly IContentTypeProvider _contentTypeProvider ;
23
- private readonly IIOHelper _ioHelper ;
24
21
private readonly string _rootUrl ;
25
22
private readonly string _containerRootPath ;
23
+ private readonly BlobContainerClient _container ;
24
+ private readonly IIOHelper _ioHelper ;
25
+ private readonly IContentTypeProvider _contentTypeProvider ;
26
26
27
27
/// <summary>
28
- /// Creates a new instance of <see cref="AzureBlobFileSystem" />.
28
+ /// Creates a new instance of <see cref="AzureBlobFileSystem" />.
29
29
/// </summary>
30
- /// <param name="options"></param>
31
- /// <param name="hostingEnvironment"></param>
32
- /// <param name="ioHelper"></param>
33
- /// <param name="contentTypeProvider"></param>
34
- /// <exception cref="ArgumentNullException"></exception>
35
- public AzureBlobFileSystem ( AzureBlobFileSystemOptions options , IHostingEnvironment hostingEnvironment ,
36
- IIOHelper ioHelper , IContentTypeProvider contentTypeProvider )
30
+ /// <param name="options">The options.</param>
31
+ /// <param name="hostingEnvironment">The hosting environment.</param>
32
+ /// <param name="ioHelper">The I/O helper.</param>
33
+ /// <param name="contentTypeProvider">The content type provider.</param>
34
+ public AzureBlobFileSystem ( AzureBlobFileSystemOptions options , IHostingEnvironment hostingEnvironment , IIOHelper ioHelper , IContentTypeProvider contentTypeProvider )
37
35
{
38
36
if ( options == null ) throw new ArgumentNullException ( nameof ( options ) ) ;
39
37
if ( hostingEnvironment == null ) throw new ArgumentNullException ( nameof ( hostingEnvironment ) ) ;
40
38
39
+ _rootUrl = EnsureUrlSeparatorChar ( hostingEnvironment . ToAbsolute ( options . VirtualPath ) ) . TrimEnd ( '/' ) ;
40
+ _containerRootPath = options . ContainerRootPath ?? _rootUrl ;
41
+ _container = new BlobContainerClient ( options . ConnectionString , options . ContainerName ) ;
41
42
_ioHelper = ioHelper ?? throw new ArgumentNullException ( nameof ( ioHelper ) ) ;
42
43
_contentTypeProvider = contentTypeProvider ?? throw new ArgumentNullException ( nameof ( contentTypeProvider ) ) ;
44
+ }
43
45
44
- _rootUrl = EnsureUrlSeparatorChar ( hostingEnvironment . ToAbsolute ( options . VirtualPath ) ) . TrimEnd ( '/' ) ;
45
- _containerRootPath = options . ContainerRootPath ?? _rootUrl ;
46
+ /// <summary>
47
+ /// Creates a new instance of <see cref="AzureBlobFileSystem" />.
48
+ /// </summary>
49
+ /// <param name="rootUrl">The root URL.</param>
50
+ /// <param name="blobContainerClient">The blob container client.</param>
51
+ /// <param name="ioHelper">The I/O helper.</param>
52
+ /// <param name="contentTypeProvider">The content type provider.</param>
53
+ /// <param name="containerRootPath">The container root path (uses the root URL if not set).</param>
54
+ public AzureBlobFileSystem ( string rootUrl , BlobContainerClient blobContainerClient , IIOHelper ioHelper , IContentTypeProvider contentTypeProvider , string ? containerRootPath = null )
55
+ {
56
+ if ( rootUrl is null )
57
+ {
58
+ throw new ArgumentNullException ( nameof ( rootUrl ) ) ;
59
+ }
46
60
47
- var client = new BlobServiceClient ( options . ConnectionString ) ;
48
- _container = client . GetBlobContainerClient ( options . ContainerName ) ;
61
+ _rootUrl = EnsureUrlSeparatorChar ( rootUrl ) . TrimEnd ( '/' ) ;
62
+ _containerRootPath = containerRootPath ?? _rootUrl ;
63
+ _container = blobContainerClient ?? throw new ArgumentNullException ( nameof ( blobContainerClient ) ) ;
64
+ _ioHelper = ioHelper ?? throw new ArgumentNullException ( nameof ( ioHelper ) ) ;
65
+ _contentTypeProvider = contentTypeProvider ?? throw new ArgumentNullException ( nameof ( contentTypeProvider ) ) ;
49
66
}
50
67
51
68
/// <inheritdoc />
0 commit comments