Hello. I need to send the file, but i have a problem with sending binary. Something wrong with handling binary data because uploader catches wrong file.
Yeah, there is no base64. So, I’m dont sending this to my script, I’m sending this to rest api server and I cant setup my conditions. Firefox spoils binary data while sending.
You can upload an arraybuffer, just do .send(arrBufHere) does that work? If you need to have a filename on it you can do send with a blob or file object as well.
You cannot send binary data via http. Therefore you base-64 encode it first. Your code does not base-64 encode the binary file contents, therefore they are not sent properly. Otherwise the code looks correct.
Various versions of Firefox provide cute ways for you to ‘‘apparently’’ send binary data through http, but behind the scenes they are just doing the encoding for you. For example you can send a Blob simply by passing it to XHR.send(), but that won’t send multipart form data so it isn’t good for you.
Firefox does include a FormData API which allows you to send multipart form data without having to construct the string yourself. You can just append key/value pairs to the FormData object and then pass it to your post request. It could be a good solution except you’ve already gone to the trouble of writing all the code to do this, so it seems a bit pointless to start again. Note that some features of the FormData API are not available in Firefox versions before 44. Also, this feature is part of the latest standard but is not well supported (or supported at all) by other browsers.
Thx for info. I need realization only for 40<=. How I can do it? With FormData (or analog) or something else. I can’t find examples with sending binary with base64 via sdk.
Now I have this. It successfully sends file to my uploader, but I need other. Target server want content-type header (commented), but how I can handle it? I’m trying to realize this api. My first script successfully sends files to target server, but having problem with binary.
Your code does not base-64 encode the binary file contents
I don’t know how to do it. Just encoding file data gives nothing (server correctly receives file consisting of base64 string ).