DxUpload.AllowPause Property
Namespace: DevExpress.Blazor
Assembly:
DevExpress.Blazor.v21.1.dll
NuGet Package:
DevExpress.Blazor
Declaration
[Parameter]
public bool AllowPause { get; set; }
Property Value
Type |
Description |
Boolean |
true to allow users to pause file upload; otherwise, false.
|
If chunk upload is enabled, users can click the pause button to pause file upload. Handle the FileUploadPaused event to respond to this action.
Users can then continue file upload.
Set the AllowPause property to false to hide the pause button during the upload process.
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/UploadFile/"
AllowPause="false">
</DxUpload>
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
[Route("api/[controller]")]
public class UploadController : ControllerBase {
private readonly IWebHostEnvironment _hostingEnvironment;
public UploadController(IWebHostEnvironment hostingEnvironment) {
_hostingEnvironment = hostingEnvironment;
}
[HttpPost]
[Route("UploadFile")]
// "myFile" is the value of the Upload's "Name" property.
public ActionResult UploadFile(IFormFile myFile) {
try {
// Specify the target location for the uploaded files.
var path = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
// Check whether the target directory exists; otherwise, create it.
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
using (var fileStream = System.IO.File.Create(Path.Combine(path, myFile.FileName))) {
// Check the file here (its extension, safity, and so on).
// If all checks are passed, save the file.
myFile.CopyTo(fileStream);
}
} catch {
Response.StatusCode = 400;
}
return new EmptyResult();
}
}
See Also