|
30 | 30 |
|
31 | 31 | const getters = ['exists', 'stat', 'readdir', 'readfile']; |
32 | 32 |
|
33 | | -const requester = core => (fn, body, type) => |
| 33 | +const requester = core => (fn, body, type, options = {}) => |
34 | 34 | core.request(`/vfs/${fn}`, { |
35 | 35 | body, |
36 | | - method: getters.indexOf(fn) !== -1 ? 'get' : 'post' |
| 36 | + method: getters.indexOf(fn) !== -1 ? 'get' : 'post', |
| 37 | + ...options |
37 | 38 | }, type) |
38 | 39 | .then(response => { |
39 | 40 | if (type === 'json') { |
@@ -64,13 +65,16 @@ const methods = (core, request) => { |
64 | 65 | readfile: ({path}, type, options) => |
65 | 66 | request('readfile', {path, options}), |
66 | 67 |
|
67 | | - writefile: ({path}, data, options) => { |
| 68 | + writefile: ({path}, data, options = {}) => { |
68 | 69 | const formData = new FormData(); |
69 | 70 | formData.append('upload', data); |
70 | 71 | formData.append('path', path); |
71 | 72 | formData.append('options', options); |
72 | 73 |
|
73 | | - return request('writefile', formData); |
| 74 | + return request('writefile', formData, undefined, { |
| 75 | + onProgress: options.onProgress, |
| 76 | + xhr: !!options.onProgress |
| 77 | + }); |
74 | 78 | }, |
75 | 79 |
|
76 | 80 | copy: (from, to, options) => |
|
0 commit comments