mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Merge pull request #6640 from Codinlab/issue/6639
Azure Media Storage doesn't recognize its own URLs Fixes #6639
This commit is contained in:
commit
5af991e516
src/Orchard.Web/Modules/Orchard.Azure/Services/FileSystems
@ -308,9 +308,9 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
|
||||
public string GetPublicUrl(string path) {
|
||||
path = ConvertToRelativeUriPath(path);
|
||||
var uri = new UriBuilder(Container.GetBlockBlobReference(String.Concat(_root, path)).Uri);
|
||||
if (!string.IsNullOrEmpty(_publicHostName)) uri.Host = _publicHostName;
|
||||
return uri.ToString();
|
||||
var uriBuilder = new UriBuilder(Container.GetBlockBlobReference(String.Concat(_root, path)).Uri);
|
||||
if (!string.IsNullOrEmpty(_publicHostName)) uriBuilder.Host = _publicHostName;
|
||||
return uriBuilder.Uri.ToString();
|
||||
}
|
||||
|
||||
private class AzureBlobFileStorage : IStorageFile {
|
||||
|
@ -4,6 +4,7 @@ using Orchard.Azure.Services.Environment.Configuration;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.FileSystems.Media;
|
||||
using System;
|
||||
|
||||
namespace Orchard.Azure.Services.FileSystems.Media {
|
||||
|
||||
@ -64,8 +65,10 @@ namespace Orchard.Azure.Services.FileSystems.Media {
|
||||
/// <returns>The corresponding local path.</returns>
|
||||
public string GetStoragePath(string url) {
|
||||
EnsureInitialized();
|
||||
if (url.StartsWith(_absoluteRoot)) {
|
||||
return HttpUtility.UrlDecode(url.Substring(Combine(_absoluteRoot, "/").Length));
|
||||
var rootUri = new Uri(_absoluteRoot);
|
||||
var uri = new Uri(url);
|
||||
if((uri.Host == rootUri.Host || (!string.IsNullOrEmpty(_publicHostName) && uri.Host == _publicHostName)) && uri.AbsolutePath.StartsWith(rootUri.AbsolutePath)) {
|
||||
return HttpUtility.UrlDecode(uri.PathAndQuery.Substring(Combine(rootUri.AbsolutePath, "/").Length));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user