33using DasBlog . Services . ConfigFile ;
44using DasBlog . Services . FileManagement ;
55using DasBlog . Services . FileManagement . Interfaces ;
6+ using DasBlog . Services . Site ;
67using Microsoft . Extensions . Options ;
78using newtelligence . DasBlog . Runtime ;
89using System ;
@@ -18,7 +19,6 @@ public class FileSystemBinaryManager : IFileSystemBinaryManager
1819 private readonly IConfigFileService < OEmbedProviders > oembedProvidersService ;
1920 private readonly IConfigFileService < SiteConfig > siteConfigFileService ;
2021 private readonly ConfigFilePathsDataOption options ;
21- private readonly string contentBinaryUrl ;
2222
2323 public FileSystemBinaryManager ( IDasBlogSettings dasBlogSettings , IConfigFileService < MetaTags > metaTagFileService ,
2424 IConfigFileService < OEmbedProviders > oembedProvidersService ,
@@ -27,17 +27,24 @@ public FileSystemBinaryManager(IDasBlogSettings dasBlogSettings, IConfigFileServ
2727 this . dasBlogSettings = dasBlogSettings ;
2828 this . metaTagFileService = metaTagFileService ;
2929 this . oembedProvidersService = oembedProvidersService ;
30- this . siteConfigFileService = siteConfigFileService ;
30+ this . siteConfigFileService = siteConfigFileService ; ;
3131 options = optionsAccessor . Value ;
32- contentBinaryUrl = dasBlogSettings . RelativeToRoot ( options . BinaryUrlRelative ) ;
3332
34- var physBinaryPathUrl = new Uri ( contentBinaryUrl ) ;
33+ Uri physBinaryPathUrl ;
3534
36- var loggingDataService = LoggingDataServiceFactory . GetService ( Path . Combine ( dasBlogSettings . WebRootDirectory , dasBlogSettings . SiteConfiguration . LogDir ) ) ;
35+ if ( ! string . IsNullOrWhiteSpace ( dasBlogSettings . SiteConfiguration . Root ) )
36+ {
37+ physBinaryPathUrl = new Uri ( dasBlogSettings . RelativeToRoot ( options . BinaryUrlRelative ) ) ;
38+ }
39+ else
40+ {
41+ physBinaryPathUrl = new Uri ( new Uri ( SiteHttpContext . AppBaseUrl ) , options . BinaryUrlRelative ) ;
42+ }
3743
44+ var loggingDataService = LoggingDataServiceFactory . GetService ( Path . Combine ( dasBlogSettings . WebRootDirectory , dasBlogSettings . SiteConfiguration . LogDir ) ) ;
3845 var cdnManager = CdnManagerFactory . GetService ( dasBlogSettings . SiteConfiguration . CdnFrom , dasBlogSettings . SiteConfiguration . CdnTo ) ;
3946
40- binaryDataService = BinaryDataServiceFactory . GetService ( options . BinaryFolder , physBinaryPathUrl , loggingDataService , cdnManager ) ;
47+ this . binaryDataService = BinaryDataServiceFactory . GetService ( options . BinaryFolder , physBinaryPathUrl , loggingDataService , cdnManager ) ;
4148 }
4249
4350 public string SaveFile ( Stream inputFile , string fileName )
0 commit comments