Large file streaming uploads
This commit is contained in:
30
Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
Normal file
30
Oqtane.Client/Modules/Admin/ModuleDefinitions/Add.razor
Normal file
@ -0,0 +1,30 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Services
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IFileService FileService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Module: </label>
|
||||
</td>
|
||||
<td>
|
||||
<FileUpload Filter=".nupkg"></FileUpload>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="UploadFile">Upload</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
private async Task UploadFile()
|
||||
{
|
||||
await FileService.UploadFilesAsync("/Sites/Modules");
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Text="Upload Module" />
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
|
43
Oqtane.Client/Modules/Controls/FileUpload.razor
Normal file
43
Oqtane.Client/Modules/Controls/FileUpload.razor
Normal file
@ -0,0 +1,43 @@
|
||||
@if (multiple)
|
||||
{
|
||||
<input type="file" id="@fileid" name="file" accept="@filter" multiple />
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="file" id="@fileid" name="file" accept="@filter" />
|
||||
}
|
||||
<span id="@progressinfoid"></span> <progress id="@progressbarid" style="visibility: hidden;"></progress>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string Name { get; set; } // optional - can be used for managing multiple file upload controls on a page
|
||||
|
||||
[Parameter]
|
||||
public string Filter { get; set; } // optional - for restricting types of files that can be selected
|
||||
|
||||
[Parameter]
|
||||
public string Multiple { get; set; } // optional - enable multiple file uploads
|
||||
|
||||
string fileid = "";
|
||||
string progressinfoid = "";
|
||||
string progressbarid = "";
|
||||
string filter = "*";
|
||||
bool multiple = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
fileid = Name + "FileInput";
|
||||
progressinfoid = Name + "ProgressInfo";
|
||||
progressbarid = Name + "ProgressBar";
|
||||
|
||||
if (!string.IsNullOrEmpty(Filter))
|
||||
{
|
||||
filter = Filter;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Multiple))
|
||||
{
|
||||
multiple = bool.Parse(Multiple);
|
||||
}
|
||||
}
|
||||
}
|
@ -67,9 +67,9 @@
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="Username" class="control-label">User: </label></td>
|
||||
<td style="text-align: right;"><label for="Username" class="control-label">User: </label></td>
|
||||
<td><input type="text" name="Username" class="form-control" placeholder="Enter Username" @bind="@username" /></td>
|
||||
<td><button type="button" class="btn btn-primary" @onclick="@AddUser">Add</button></td>
|
||||
<td style="text-align: left;"><button type="button" class="btn btn-primary" @onclick="@AddUser">Add</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -5,6 +5,6 @@
|
||||
SecurityAccessLevel SecurityAccessLevel { get; } // defines the security access level for this control - defaults to View
|
||||
string Title { get; } // title to display for this control - defaults to module title
|
||||
string Actions { get; } // allows for routing by configuration rather than by convention ( comma delimited ) - defaults to using component file name
|
||||
string ContainerType { get; } // container for embedding control - defaults to AdminContainer
|
||||
bool UseAdminContainer { get; } // container for embedding module control - defaults to true
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Oqtane.Modules
|
||||
|
||||
public virtual string Actions { get { return ""; } }
|
||||
|
||||
public virtual string ContainerType { get { return ""; } }
|
||||
public virtual bool UseAdminContainer { get { return true; } }
|
||||
|
||||
public string NavigateUrl()
|
||||
{
|
||||
|
Reference in New Issue
Block a user