I am trying to form a Content-Type: application/octet-stream
PUT request from JavaScript where the body will be raw binary (byte[]
). I have a Base-64 encoded string of the binary data which is a random file content. I need to decode this back to a byte array and put it into the request body.
The curl
command I could use to do this is:
curl -v -X PUT --header "Content-Type:application/octet-stream" --data-binary "@myfile" http://localhost:8080/my-services/myapi
How can I do that in JavaScript?