mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#20384: Public host name for Azure storage can be defined with a setting, based on the previous changes (Orchard.Azure)
Work Item: 20384
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
public const string MediaStorageFeatureName = "Orchard.Azure.Media";
|
||||
public const string MediaStorageStorageConnectionStringSettingName = "Orchard.Azure.Media.StorageConnectionString";
|
||||
public const string MediaStorageContainerName = "media"; // Container names must be lower case.
|
||||
public const string MediaStoragePublicHostName = "Orchard.Azure.Media.StoragePublicHostName";
|
||||
|
||||
public const string OutputCacheFeatureName = "Orchard.Azure.OutputCache";
|
||||
public const string OutputCacheSettingNamePrefix = "Orchard.Azure.OutputCache.";
|
||||
|
@@ -17,6 +17,7 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
|
||||
protected string _root;
|
||||
protected string _absoluteRoot;
|
||||
protected string _publicHostName;
|
||||
|
||||
private CloudStorageAccount _storageAccount;
|
||||
private CloudBlobClient _blobClient;
|
||||
@@ -46,12 +47,13 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
}
|
||||
}
|
||||
|
||||
public AzureFileSystem(string storageConnectionString, string containerName, string root, bool isPrivate, IMimeTypeProvider mimeTypeProvider) {
|
||||
public AzureFileSystem(string storageConnectionString, string containerName, string root, bool isPrivate, IMimeTypeProvider mimeTypeProvider, string publicHostName = null) {
|
||||
_isPrivate = isPrivate;
|
||||
_mimeTypeProvider = mimeTypeProvider;
|
||||
StorageConnectionString = storageConnectionString;
|
||||
ContainerName = containerName;
|
||||
_root = String.IsNullOrEmpty(root) ? "" : root + "/";
|
||||
_publicHostName = publicHostName;
|
||||
}
|
||||
|
||||
private void EnsureInitialized() {
|
||||
@@ -287,7 +289,8 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
|
||||
public string GetPublicUrl(string path) {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
return Container.GetBlockBlobReference(String.Concat(_root, path)).Uri.ToString();
|
||||
var uri = Container.GetBlockBlobReference(String.Concat(_root, path)).Uri;
|
||||
return string.IsNullOrEmpty(_publicHostName) ? uri.ToString() : uri.ToString().Replace(uri.Host, _publicHostName);
|
||||
}
|
||||
|
||||
private class AzureBlobFileStorage : IStorageFile {
|
||||
|
@@ -12,11 +12,13 @@ namespace Orchard.Azure.Services.FileSystems.Media {
|
||||
public class AzureBlobStorageProvider : AzureFileSystem, IStorageProvider {
|
||||
|
||||
public AzureBlobStorageProvider(ShellSettings shellSettings, IMimeTypeProvider mimeTypeProvider, IPlatformConfigurationAccessor pca)
|
||||
: this(pca.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null), Constants.MediaStorageContainerName, shellSettings.Name, mimeTypeProvider) {
|
||||
: this(pca.GetSetting(Constants.MediaStorageStorageConnectionStringSettingName, shellSettings.Name, null),
|
||||
Constants.MediaStorageContainerName, shellSettings.Name, mimeTypeProvider,
|
||||
pca.GetSetting(Constants.MediaStoragePublicHostName, shellSettings.Name, null)) {
|
||||
}
|
||||
|
||||
public AzureBlobStorageProvider(string storageConnectionString, string containerName, string rootFolderPath, IMimeTypeProvider mimeTypeProvider)
|
||||
: base(storageConnectionString, containerName, rootFolderPath, false, mimeTypeProvider) {
|
||||
public AzureBlobStorageProvider(string storageConnectionString, string containerName, string rootFolderPath, IMimeTypeProvider mimeTypeProvider, string publicHostName)
|
||||
: base(storageConnectionString, containerName, rootFolderPath, false, mimeTypeProvider, publicHostName) {
|
||||
}
|
||||
|
||||
public bool TrySaveStream(string path, Stream inputStream) {
|
||||
|
Reference in New Issue
Block a user