(url: string, file: File, onProgress: (event: ProgressEvent<EventTarget>) => void)
| 24 | } |
| 25 | |
| 26 | function upload(url: string, file: File, onProgress: (event: ProgressEvent<EventTarget>) => void) { |
| 27 | return new Promise((res, rej) => { |
| 28 | const xhr = new XMLHttpRequest(); |
| 29 | xhr.open('PUT', url); |
| 30 | |
| 31 | xhr.onload = e => { |
| 32 | res("") |
| 33 | }; |
| 34 | xhr.onerror = rej; |
| 35 | if (xhr.upload && onProgress) |
| 36 | xhr.upload.onprogress = onProgress; |
| 37 | xhr.send(file); |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | useEffect(() => { |
| 42 | if (file === null) return |
no outgoing calls
no test coverage detected
searching dependent graphs…