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
navigation.addEventListener("navigate",(e)=>{if(e.downloadRequest){e.intercept({handler: async()=>{consturl=newURL(e.destination.url);constparams=Object.fromEntries(url.searchParams.entries());const{ fileType }=params;// additional metadata// get a file handle and create writable streamconstfileHandle=awaitwindow.showSaveFilePicker({types: [FileTypes[fileType]],suggestedName: e.downloadRequest});constwritable=awaitfileHandle.createWritable();// manually fetch the file and write to fileHandleconst{ body }=awaitfetch(url);body?.pipeTo(writable);}});}});
However currently this snippet causes the download request to become a "real" push navigation and I end up at the destination URL, in this case src/assets/art.jpeg?fileType=jpeg.
Coming from the model of how unintercepted download requests work where they don't actually push on to the history stack this is a bit confusing and leaves me feeling like I'm missing something here.
The text was updated successfully, but these errors were encountered:
I was testing the use case of extending the download behaviour of anchor tags. For example we might want to extend it with the File System API:
However currently this snippet causes the download request to become a "real" push navigation and I end up at the destination URL, in this case
src/assets/art.jpeg?fileType=jpeg
.Coming from the model of how unintercepted download requests work where they don't actually push on to the history stack this is a bit confusing and leaves me feeling like I'm missing something here.
The text was updated successfully, but these errors were encountered: