50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Blog3000.Client.Pages
|
|
{
|
|
public partial class PublicDl
|
|
{
|
|
|
|
/* Download within the url-space the blog
|
|
* Authors can Download from /PublicDl/myfile
|
|
* Server will be asked for actual url and the
|
|
* and the download will be initiated from this url.
|
|
* Server may anonymously count downloads, or create
|
|
* one-time-urls for protected DLs.
|
|
* Download-counting could be readlized with <a href.... ping=myserver" as well
|
|
*
|
|
* The download-server should have another domain than the blog currently,
|
|
* since otherwise the blogs router may take over and display a not found.
|
|
*
|
|
* Otherwise we would need a own javascript based downloader, which may
|
|
* be excessive work currently
|
|
*
|
|
*/
|
|
|
|
[Parameter]
|
|
public string Filename
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public string FinalUrl;
|
|
|
|
[Inject]
|
|
private HttpClient HttpClient { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
FinalUrl = await HttpClient.GetStringAsync($"PublicDl/{Filename}/getredirurl");
|
|
this.StateHasChanged();
|
|
|
|
await jsRuntime.InvokeVoidAsync("downloadURI", $"{FinalUrl}", ""); ;
|
|
}
|
|
}
|
|
}
|