mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Fix direct URL for local storage with custom root path (#2318)
* Fix direct URL for local storage with custom root path * Remove "Context.Request.PathBase" when generating file URL display string
This commit is contained in:
parent
e8df010449
commit
c9cfe5cc6e
@ -37,7 +37,9 @@ namespace BTCPayServer.Storage.Services.Providers.FileSystemStorage
|
||||
public override async Task<string> GetFileUrl(Uri baseUri, StoredFile storedFile, StorageSettings configuration)
|
||||
{
|
||||
var baseResult = await base.GetFileUrl(baseUri, storedFile, configuration);
|
||||
var url = new Uri(baseUri, LocalStorageDirectoryName);
|
||||
// Set the relative URL to the directory name if the root path is default, otherwise add root path before the directory name
|
||||
var relativeUrl = baseUri.AbsolutePath == "/" ? LocalStorageDirectoryName : $"{baseUri.AbsolutePath}/{LocalStorageDirectoryName}";
|
||||
var url = new Uri(baseUri, relativeUrl);
|
||||
return baseResult.Replace(new DirectoryInfo(_datadirs.Value.StorageDir).FullName, url.AbsoluteUri,
|
||||
StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
@ -64,13 +64,13 @@ else
|
||||
@Url.Action("GetFile", "Storage", new
|
||||
{
|
||||
fileId = Model.SelectedFileId
|
||||
}, Context.Request.Scheme, Context.Request.Host.ToString(), Context.Request.PathBase.ToString())
|
||||
}, Context.Request.Scheme, Context.Request.Host.ToString())
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item ">
|
||||
<div class="row px-0 mx-0">
|
||||
<span class="col-sm-12 col-md-2">Direct Url </span>
|
||||
<span class="col-sm-12 col-md-2">Direct Url: </span>
|
||||
<a class="col-sm-12 col-md-10 text-right" href="@Model.DirectFileUrl" target="_blank">@Model.DirectFileUrl</a>
|
||||
</div>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user