I want to send a blob using a JQuery ajax request and receive it server-side with Node.js + express.
I would send the blob as a JSON string, but it seems that none of the binary data is included in it:
{"type":"audio/wav","size":344108}
How else could it be sent?
JSON doesn't support binary data. You will have to encode your binary data first: Binary Data in JSON String. Something better than Base64
Related
I need to send SVG-element to server and then rewrite SVG-file in folder. But i dont understand how to get element in request.body, its "undefined".
It's my fetch
Well, i find the answer.
You need to convert svg-element to base64, before send it to server.
On the server you need to create buffer from request.body and then convert it to string
I have an ArrayBuffer in angularjs that I am trying to send to my backend endpoint in c#, I thought it was a regular byte array but it's not mapping appropriately
What would an ArrayBuffer map to as an object in c# if not a byte[]?.
I have a PDF file represented as that ArrayBuffer but now I would like to send it to the server, or perhaps is there a way to convert that ArrayBuffer to a File type in JavaScript and send it o the endpoint so that I can use something like an IFormFile?.
Thank you
I had a situation of same some long days back. What I did was, I converted the array buffer data to base 64 string in the js side and sent it to the backend c# code using post method,and again I decoded it to array buffer to regenerate the file on server side. By this way I achieved the mapping.
I used this code which helps to convert the array buffer to base 64 string in JS.
and this api of .net framework to convert back the base 64 string to file buffer.
I hope this would help you.
Is there a way to embed HTML into JSON?
I have formatted HTML data in my database. I am querying this database and serializing the response to JSON. However, when I incorporate this JSON into my web page, its not what I expect!
SQL returned data:
<b>Trolo:</b><br/><b><a target="_blank" class="trololo" href="http://trololooo">TROLOLOLOOO</a></b>
JSON returned data:
"TROLO":"\u003cb\u003eTrolo:\u003c/b\u003e\u003cbr/\u003e\u003cb\u003e\u003ca target=\"_blank\" class=\"trololo\" href=\"http://trololooo\"
Should I be doing some kind of encoding of the HTML data when it is serialized into JSON?
Use URL-encoding and URL-decoding to encode and decode your HTML.
This might also be helpful: https://stackoverflow.com/a/4292961/1182823
In your scenario, it seems you'll have to do the encoding on your server-side (e.g. with PHP before saving data in the database).
I have a file chunking operation that splits a file via File Reader into slices which are read via readAsArrayBuffer. I would like to send those chunks one at a time over my data channel WITH meta information attached (a chunk id, for instance). Like:
// Build chunk wrapper
var block = {
chunkId: id,
data: buffer
};
// Send the chunk to peer
channel.send(JSON.stringify(block));
Now when I send that data as is demonstrated above the data in the ArrayBuffer buffer is lost. I would like to emphasize I'm not having any trouble sending data over my data channel.
I would like to know how I can send that data with its associated meta information so that the file chunks can be reassembled in the correct order on the other side?
Do I need to do something like make an ArrayBuffer with two sub arrays, one with the meta information, and the other with the actual data or is there a simpler way?
There are many ways you can solve this, but basically you'll need to serialize, encode and deserialize, decode your data.
If you want to send your metadata with the data, you'll need to either serialize both to a uint8array or to a string, and do the inverted operation on the receiver side.
For example Sharefest utilizes a TLV protocol: https://github.com/Peer5/ShareFest/blob/master/core/protocol/BinaryProtocol.js
is this possible to send cross site request by AJAX with a SOAP request and get XML response?
and i want to convert my xml response to json format is there any framework (like mustache) to do this easily
You can make use of xml2js node library. It converts xml to json and vice versa. But it doesn't uses templates. https://www.npmjs.com/package/xml2js