I'm little confused about sending audio files from my client app (max. 10 sec of audio) into my server. The question is - which of the following options is the best?
From the client side save audio file into byte array and then convert it into Base64. After that send it in json request. On the server side, handle request in a Rest Api, decode Base64 and save it on the server. I was also wondering about making hash function of the audio file from the client side and send it also with the response and from the api compare these two hashes for integrity purposes (Missing packets or something).
Send an audio file as multipart form-data in json response and handle it in my Rest Api.
Simply saving file using FTP into my server.
Which option is the best? Or do you have any ideas?
Related
I am working on teaching myself more about TLS and Wireshark, and seem to be stuck.
I am currently capturing the SSL keys for client/server communications while I am copying a file from my client to my own OneDrive session. I am able to decrypt the TLS stream in Wireshark, and I can see the entire transmission of my file to the host, but I cannot export the file object from that stream. It appears to be inside json, and I don't know a thing about json.
Essentially what I am doing is looking at the characteristics of Data Exfiltration and Data Loss Prevention.
Thanks for your help.
I am writing rest api with Flask. One of my endpoints handles a post request. One field of the request JSON 'audio' is supposed to contain the BASE64 encoded PCM file (audio format). If save this field to a file, it is about 200KB.
It might be too big to copy and paste in Swagger or Postman for testing. Even worse with curl command. Is there any good way to test with really big JSON in the request.
I'd recommend a great tool called Insomnia. You can send point it to any file to send it as a HTTP request. You can change the Content-Type header to be application/json and select your JSON data file. Here's a screenshot of what the program looks like.
My application is based on AngularJS, totally client-side; the server is based on Express JS. For data communication I am using the http post method. When I send a http request, the server responds with data in JSON format, but all the JSON data shows in the client browser. I don't want to show JSON data in client browser.
Is there any way to hide or secure json data in client browser?
What ever the response you will send, will be shown at the client-end. If you want to hide some data, you can always encrypt them and send it. One of the useful tool for such is Crypto-JS.
User will still see the data but as it will be encrypted, he cannot understand it.
But, still it is safer not to send user-sensitive data to client-side.
Is there any limit on sending JSON data to a rest API?I am building an app where I have used a rest API to send an email. Here I want to send app logs to API,but before going through that I want to know about the limitation on send data to rest API.
Secondly which one is better option file or send JSON data to rest API?
In ASP.NET there's by default a 4MB limit of the size of a request. This can be adjusted using the maxRequestLength attribute on the httpRuntime element:
<httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" />
In this example we set the maximum request size to be 1GB.
Secondly which one is better option file or send JSON data to rest API?
If you are planning to send large request payloads I would recommend you using the multipart/form-data content type for the request instead of JSON. This would allow you to directly send the raw bytes in the request payload. If you use JSON then you would need to encode those raw bytes to something like base64 which would make the request even larger. To even further optimize network traffic the client could gzip the raw bytes before sending them over the wire and then unzip the stream on the server.
You may also find the following article useful in setting up this file upload on the server side.
Hi I would like to stream data from my webserver.
here is the catch. The data does not exist on my server I retrieve it as a live content from another server.
So I do not have the size of the file. How do I stream this data.?
I read PCM in chunks (OF DIFFERENT SIZES) convert it to OGG.
Send the OGG HEADER and the OGG CONTENT down to html5 audio tag
Or at least this is what I want to do.
recap :
I am server "A",
There is another server "B" which servers PCM data.
Client request comes from an AUDIO tag from HTML5 to server A to get the Data In server B( This data does not have a size,constant streaming).
A recieves PCM from B
Converts to OGG.
Sends it along the http response object as binary data.
Any ideas.
HTTP/1.1 supports chunked encoding exactly for this use case.