How do I upload a file without saving it to Wix's storage?

I searched the forums but all I could find were these unanswered questions: https://www.wix.com/corvid/forum/community-discussion/upload-file-to-external-file-storage & https://www.wix.com/corvid/forum/community-discussion/can-w-uploadbutton1-value-be-converted-to-blob

The only way I can find to upload a file with Wix is to use the ‘Upload Button’, but this uploads the file to the site’s storage. I need to send the file to an external endpoint and I cannot store the file on Wix because it needs to be visible only to that user due to privacy policy.

I’ve tried creating a hidden file input but ‘document’ is undefined; we’re forced to use Wix’s $w(..) api. Is there any way around uploading the file to Wix?

https://www.wix.com/corvid/forum/community-discussion/upload-wix-media-backend-filecontent/ and REST API to external storage.

Use FETCH or XMLHTTPREQUEST

Or HTML Element with + FETCH or XMLHTTPREQUEST

I tried to use a HTML element, but it doesn’t seem possible: There is no document object that I can use to create arbitrary elements from javascript.

The post that you linked is about uploading to the media manager, whereas I am trying to upload it to a 3rd party service via a rest api. Are you saying that I should be uploading to the wix storage and then uploading the file to the 3rd party and deleting it from wix storage? (seems very heavy-handed)

The post is an example how to use upload on backend.
Upload to external (fetch) instead wix-media.
That uses Buffer module and Base64.
Depending on the external storage you will need upload on base64 and/or to control the chunks (group of bytes).
Backend has a limit about 10MB. Use HTML Element instead.

How do you suggest using a HTML Element instead? It doesn’t seem possible to add one (“document is undefined”)

HTML element is a IFrame element. Drag and drop from “+” => Embed => widget or site. Create a HTML/SCRIPTED code and insert on that element. Use onmessage/postmessage for exchange data to.
That element is a Vanilla web component and you have Window, Document global classes.