hoppscotch / hoppscotch-extension

🧩 Browser extensions to provide more capabilities to https://hoppscotch.io
https://hoppscotch.io
MIT License
254 stars 92 forks source link

[feature]: Large file upload #302

Open zhangtao25 opened 1 year ago

zhangtao25 commented 1 year ago

Is there an existing issue for this?

Summary

When using the chorme extensions proxy to upload files, due to the limitations of the chrome extensions, the file cannot be serialized, which requires a base64 encoding before transferring data through postmessage, resulting in large files being unable to be uploaded and used on the hoppscotch.

Why should this be worked on?

Support for uploading large files on hoppscotch.

semi-infiknight commented 2 months ago

Hi, I have taken part in FOSS Hack 2024 and have taken an interest in this issue. My approach for solving this issue would be to use chunked file uploading.

Please assign me this issue so that I can start working on it.

amk-dev commented 1 month ago

Hey @semi-infiknight

sorry for the late reply. you can work on this. i'll give some additional context also,

so right now the process of transfering a file to the extension looks like this,

hoppscotch website -> hookContent.js -> contentScript -> serviceWorker -> sents the request.

the bottleneck is in the contentScript, it uses the chrome.runtime.sendMessage which can only transfer JSON serializable values. the window.postMessage supports the StructuredCloneAlgorithm which supports the File object. we can use postMessage in hookContent.js, so we can transfer the file till contentScript with this. but from there we need to use chrome.runtime.sendMessage which only accepts JSON serializable values.

there are some paths you could explore to solve this. linking the ongoing discussion about this topic here. there are some workarounds listed there. you'll need to explore these before going the splitting the file and rejoining path. you can use it as a last resort.

https://github.com/w3c/webextensions/issues/293