Save data as a file download on the filesystem. For file upload use the InputFile component.
public sealed partial class ExampleComponent : ComponentBase {
[Inject]
public required IDownload Download { private get; init; }
private async Task Example() {
await Download.DownloadAsFile("example.txt", "example content");
}
}
Name | Parameters | ReturnType | Description |
---|---|---|---|
DownloadAsFile | string fileName, string fileContent, [CancellationToken cancellationToken = default] | ValueTask | Triggers a download by adding an <a>-element to the document and simulate a click on it. |
DownloadAsFile | string fileName, byte[] fileContent, [CancellationToken cancellationToken = default] | ValueTask | Triggers a download by adding an <a>-element to the document and simulate a click on it. |
DownloadAsFile | string fileName, DotNetStreamReference fileContent, [CancellationToken cancellationToken = default] | ValueTask | Triggers a download by adding an <a>-element to the document and simulate a click on it. |
Note: IDownloadInProcess does not exist, because method DownloadAsFile is itself an asynchronous operation.