Skip to content

Commit ebdd972

Browse files
committed
Added progress event option for VFS writefile
1 parent 517c088 commit ebdd972

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/adapters/vfs/system.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030

3131
const getters = ['exists', 'stat', 'readdir', 'readfile'];
3232

33-
const requester = core => (fn, body, type) =>
33+
const requester = core => (fn, body, type, options = {}) =>
3434
core.request(`/vfs/${fn}`, {
3535
body,
36-
method: getters.indexOf(fn) !== -1 ? 'get' : 'post'
36+
method: getters.indexOf(fn) !== -1 ? 'get' : 'post',
37+
...options
3738
}, type)
3839
.then(response => {
3940
if (type === 'json') {
@@ -64,13 +65,16 @@ const methods = (core, request) => {
6465
readfile: ({path}, type, options) =>
6566
request('readfile', {path, options}),
6667

67-
writefile: ({path}, data, options) => {
68+
writefile: ({path}, data, options = {}) => {
6869
const formData = new FormData();
6970
formData.append('upload', data);
7071
formData.append('path', path);
7172
formData.append('options', options);
7273

73-
return request('writefile', formData);
74+
return request('writefile', formData, undefined, {
75+
onProgress: options.onProgress,
76+
xhr: !!options.onProgress
77+
});
7478
},
7579

7680
copy: (from, to, options) =>

0 commit comments

Comments
 (0)