-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
127 lines (113 loc) · 3.11 KB
/
index.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
$(() => {
baseUrl = 'https://localhost:52366/api/AmazonS3';
amazon = new AmazonFileSystem(baseUrl, onRequestExecuted);
const provider = new DevExpress.fileManagement.CustomFileSystemProvider({
getItems,
createDirectory,
renameItem,
deleteItem,
copyItem,
moveItem,
uploadFileChunk,
downloadItems,
abortFileUpload,
});
$('#file-manager').dxFileManager({
fileSystemProvider: provider,
allowedFileExtensions: [],
upload: {
chunkSize: 5242880,
},
permissions: {
download: true,
create: true,
copy: true,
move: true,
delete: true,
rename: true,
upload: true,
},
});
});
async function getItems(item) {
try {
return amazon.getItems(item.key);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function createDirectory(parentDirectory, name) {
try {
await amazon.createDirectory(parentDirectory.key, name);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function renameItem(item, name) {
try {
await amazon.renameItem(item.key, item.parentPath, name);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function deleteItem(item) {
try {
await amazon.deleteItem(item.key);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function copyItem(item, destinationDirectory) {
try {
await amazon.copyItem(item, destinationDirectory);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function moveItem(item, destinationDirectory) {
try {
await amazon.moveItem(item, destinationDirectory);
} catch (error) {
throw new DevExpress.fileManagement.FileSystemError(32767, item, error.message);
}
}
async function abortFileUpload(fileData, uploadInfo, destinationDirectory) {
try {
await amazon.abortFileUpload(fileData, uploadInfo, destinationDirectory);
} catch (error) {
throw new Error(error.message);
}
}
async function uploadFileChunk(fileData, uploadInfo, destinationDirectory) {
try {
await amazon.uploadFileChunk(fileData, uploadInfo, destinationDirectory);
} catch (error) {
throw new Error(error.message);
}
}
async function downloadItems(items) {
try {
await amazon.downloadItems(items);
} catch (error) {
throw new Error(error.message);
}
}
function onRequestExecuted(e) {
$('<div>')
.addClass('request-info')
.append(
createParameterInfoDiv('Method:', e.method),
createParameterInfoDiv('Url path:', e.urlPath),
createParameterInfoDiv('Query string:', e.queryString),
$('<br>'),
)
.prependTo('#request-panel');
}
function createParameterInfoDiv(name, value) {
return $('<div>')
.addClass('parameter-info')
.append(
$('<div>').addClass('parameter-name').text(name),
$('<div>').addClass('parameter-value dx-theme-accent-as-text-color').text(value).attr('title', value),
);
}