Hi Team,
I'm building a chrome extension where I get a file as input from the user and pass it to my `background.js` (service worker in case of manifest v3) to save it to my backend. Since making cross-origin requests are blocked from content scripts I have to pass the same to my `background.js` and use `FETCH` API to save the file. When I pass the `FormData` or `File Object` to the chrome.runtime.sendMessage API uses JSON Serialization and what I receive in my `background.js` is an empty object. Refer to the snippet I attached in the StackOverflow here.
The same happens even when we pass the `FormData` from the content script.
I referred to multiple solutions suggested by the old StackOverflow questions, to use `URL.createObjectURL(myfile);` and pass the URL to my background.js and fetch the same file. Whereas FETCH API does not support blob URL to fetch and also XMLHttpRequest is not supported in service worker as recommended here. Can someone help me in solving this? Am so blocked with this behaviour.
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/6bac2af9-dde4-42c5-911e-014c5d6c9f3bn%40chromium.org.