POST binary file to server through GM_xmlhttpRequest.data - convert ArrayBuffer to something usable
Simply use FormData API:
GM_xmlhttpRequest({
method: 'POST',
url: 'https://catbox.moe/user/api.php',
data: new FormData({
reqtype: 'fileupload',
userhash,
fileToUpload: result,
}),
});
So there should be no need to set any headers at all.
Thanks!
POST binary file to server through GM_xmlhttpRequest.data - convert ArrayBuffer to something usable
Please advice, I have initialized var file of File type, and I need to send it's raw content through POST method. This snippet doesn't work, because result isn't added to string as raw sequence of buffer bytes but typename literally. If I understand well, JS string isn't suitable for holding binary data. What I need is to build data var from beginning as binary buffer, adding there everything necessary incl. the ArrayBuffer received as result, and so passing to GM_xmlhttpRequest. Thanks