({url, name, cors, file, onProgress, onLoad, onError, withCredentials})
| 17 | } |
| 18 | |
| 19 | function ajaxUpload({url, name, cors, file, onProgress, onLoad, onError, withCredentials}) { |
| 20 | let data = new FormData(); |
| 21 | data.append(name, file); |
| 22 | |
| 23 | let xhr = createCORSRequest('post', url, cors); |
| 24 | xhr.withCredentials = withCredentials; |
| 25 | xhr.upload.addEventListener('progress', onProgress, false); |
| 26 | xhr.onload = onLoad; |
| 27 | xhr.onerror = onError; |
| 28 | xhr.send(data); |
| 29 | |
| 30 | return xhr; |
| 31 | } |
| 32 | |
| 33 | module.exports = function (args) { |
| 34 | return ajaxUpload(args); |
no test coverage detected
searching dependent graphs…