Repository navigation
Expand file tree
/
Copy pathFileManagerApiController.cs
More file actions
43 lines (40 loc) · 1.78 KB
/
Copy pathFileManagerApiController.cs
File metadata and controls
43 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DevExtreme.AspNet.Mvc.FileManagement;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace T845880.Controllers {
public class FileManagerApiController : ControllerBase {
public IWebHostEnvironment HostingEnvironment { get; }
public FileManagerApiController(IWebHostEnvironment hostingEnvironment) {
HostingEnvironment = hostingEnvironment;
}
public object FileSystem(FileSystemCommand command, string arguments) {
var config = new FileSystemConfiguration {
Request = Request,
FileSystemProvider = new PhysicalFileSystemProvider(Path.Combine(HostingEnvironment.WebRootPath, "SampleDocs")),
AllowCopy = true,
AllowCreate = true,
AllowMove = true,
AllowDelete = true,
AllowRename = true,
AllowUpload = true,
AllowDownload = true,
AllowedFileExtensions= new string[] {".xlsx", ".rtf", ".txt", ".docx", ".json", ".jpg" }
};
var processor = new FileSystemCommandProcessor(config);
var result = processor.Execute(command, arguments);
return result.GetClientCommandResult();
}
string GetFileItemUrl(FileSystemInfo fileSystemItem) {
var relativeUrl = fileSystemItem.FullName
.Replace(HostingEnvironment.WebRootPath, "")
.Replace(Path.DirectorySeparatorChar, '/');
return $"{Request.Scheme}://{Request.Host}{Request.PathBase}{relativeUrl}";
}
}
}