Add onUploadProgress option #632

Openjadedevin13 wants to merge 12 commits into main from jadedevin13/main· opened 4 days ago
+139−5
jadedevin13 commented 4 days agoAuthor

Adds an onUploadProgress option, the counterpart of onDownloadProgress.

  • When the option is set, the request body is wrapped in a ReadableStream that reports {percent, transferredBytes, totalBytes} as chunks are read.
  • The total size is estimated from the body (FormData, Blob, ArrayBuffer, string, URLSearchParams, typed arrays).
  • 100% is reported once the stream is done.
  • DownloadProgress is renamed to Progress so both handlers share one type.
  • Throws when request streams are not supported in the environment.
  • Tests in test/upload-progress.ts.
jadedevin13 added 12 commits 4 days ago
Add onUploadProgress option31c4955
Add onUploadProgress to registry32c496e
Update to use globalThis.Response to getReader instead of Blob33c4988
Update onUploadProgress to report done progress34c49a1
Reuse DownloadProgress to Progress2dc48f1
update progress type in test2ec490a
add doc for onUploadProgress2fc4923
add tests for upload progress30c493c
fix type error for getTotalBytes39c4a1f
fix type error for getTotalBytes3ac4a38
remove log for test in uploadprogressca79810
Change error message for request stream onUploadProgress stream supportc9797f7

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick