|
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
}); |
|
var obj = {
uploadFiles: [],
action: "Save",
path: "/",
data: {
path: null,
action: null,
newName: null,
names: null,
name: "Downloads",
size: 0,
previousName: null,
dateModified: "2019-07-22T11:23:46.7153977 00:00",
dateCreated: "2019-07-22T11:26:13.9047229 00:00",
hasChild: false,
isFile: false,
type: "",
id: null,
filterPath: "\\",
targetPath: null,
renameFiles: null,
uploadFiles: null,
caseSensitive: false,
searchString: null,
showHiddenItems: false,
_fm_iconClass: null,
_fm_id: "fe_tree_1",
_fm_pId: null,
_fm_selected: false,
_fm_icon: null,
data: null,
targetData: null,
permission: null
}
}; |
|
{
action:"download",
path:"/",
names:["1.png"],
data:[
{
path:null,
action:null,
newName:null,
names:null,
name:"1.png",
size:49792,
previousName:null,
dateModified:"2019-07-22T12:15:45.0972405+00:00",
dateCreated:"2019-07-22T12:15:45.0816042+00:00",
hasChild:false,
isFile:true,
type:".png",
id:null,
filterPath:"\\",
targetPath:null,
renameFiles:null,
uploadFiles:null,
caseSensitive:false,
searchString:null,
showHiddenItems:false,
_fm_iconClass:"e-fe-image",
_fm_id:null,
_fm_pId:null,
_fm_selected:false,
_fm_icon:null,
data:null,
targetData:null,
permission:null,
_fm_created:"2019-07-22T12:15:45.081Z",
_fm_modified:"2019-07-22T12:15:45.097Z",
_fm_imageAttr:
{
alt:"1.png"
},
_fm_htmlAttr:
{
class:"e-large-icon",
title:"1.png"
}
}
]
} |
|
private void DownloadDoc()
{
this.filemanager.DownloadFilesAsync(filemanager.SelectedItems);
} |
|
@using Syncfusion.Blazor.Buttons
@inject IJSRuntime jsRuntime
<SfButton CssClass="e-small e-info " Type="button" IsPrimary=false OnClick="Download">Click</SfButton>
@code{
public class DirectoryContent
{
public DirectoryContent[] Data { get; set; }
public string FilterPath { get; set; }
public string Id { get; set; }
public string Type { get; set; }
public bool IsFile { get; set; }
public bool HasChild { get; set; }
public long Size { get; set; }
public string Name { get; set; }
public string[] Names { get; set; }
public string Action { get; set; }
public string Path { get; set; }
}
public string DownloadUrl { get; set; }
private async Task Download()
{
DirectoryContent[] data = new DirectoryContent[]{ new DirectoryContent()
{
Name = "img", // name of the file
IsFile = false, // indicates whether file or folder
FilterPath = "/", // path of the file/folder from root directory
HasChild = true, // if folder has child folder set as true else false
Type = "" // empty string for folder and file type like .png for files
} };
DirectoryContent downloadData = new DirectoryContent()
{
Data = data,
Path = "/",// path in which the file is located (make ensure to add the path from root directory excluding the root directory name)
Names = new string[] { "img" } // names of the files to be downloaded in the specified path
};
await jsRuntime.InvokeAsync<object>("saveFile", downloadData, DownloadUrl);
}
} |
|
<script>
window.saveFile = (data, downloadUrl) => {
//creating the data to call download web API method
var i = {
action: "download",
path: data.path,
names: data.names,
data: data.data
}
, a = ej.base.createElement("form", {
id: "sample_downloadForm",
attrs: {
action: downloadUrl,
method: "post",
name: "downloadForm",
download: ""
}
})
, s = ej.base.createElement("input", {
id: "sample_hiddenForm",
attrs: {
name: "downloadInput",
value: JSON.stringify(i),
type: "hidden"
}
});
//appeding the dynamically created form to the document and perform form sumbit to perform download operation
a.appendChild(s),
document.body.appendChild(a),
document.forms.namedItem("downloadForm").submit(),
document.body.removeChild(a)
}
</script> |