You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the file does get uploaded etc... but it never goes into the console log of the progress function.
i tried to do it with middlewares like this and it works but i dont think this is a good implementation it just was for testing purposes...
```
(next) => (url, opts) => {
// Custom middleware to handle progress
const totalSize = file.size
let loadedSize = 0
const abortController = new AbortController()
const signal = abortController.signal
// Attach progress event listener
file.stream().pipeTo(
new WritableStream({
write: (chunk) => {
loadedSize += chunk.length
onprogress?.(loadedSize, totalSize)
},
}),
{ signal }
)
return next(url, { ...opts, signal })
},
am i missing something? is it a bug?
The text was updated successfully, but these errors were encountered:
The progress addon only handles download progress.
i tried to do it with middlewares like this and it works but i dont think this is a good implementation it just was for testing purposes...
As of today there is no easy way to handle progress with fetch unfortunately. For what it's worth, I think your middleware implementation is fine, I would just add a way to pass the content length from the outside instead of relying on the file.
hey im using "wretch": "^2.8.0",
im trying to convert my axios call into wretch and im having a problem with the progress addon.
my axios call was:
and my wretch call looks like:
the file does get uploaded etc... but it never goes into the console log of the progress function.
i tried to do it with middlewares like this and it works but i dont think this is a good implementation it just was for testing purposes...
```
(next) => (url, opts) => {
// Custom middleware to handle progress
const totalSize = file.size
let loadedSize = 0
const abortController = new AbortController()
const signal = abortController.signal
// Attach progress event listener
file.stream().pipeTo(
new WritableStream({
write: (chunk) => {
loadedSize += chunk.length
onprogress?.(loadedSize, totalSize)
},
}),
{ signal }
)
return next(url, { ...opts, signal })
},
The text was updated successfully, but these errors were encountered: