Send a bytes image to a api - vb.net

i have an api that recieves an image in byte, but for some reason to the api arrives an empty parameter, what do i am doing wrong?
i send this from postman to the api, the image is the only parameter that doesnt arrive correctly

Related

How to upload image with Socket Ktor?

I want to send image in Socket.
How can I do that with Ktor?
AFAIK , you cannot do like http multi part upload in websockets directly.
Several things you can try.
Try convert the image into Base64/Byte Array in client and send it to websocket server.
Several things you may need to handle is, if you use byte array you might need to handle file headers in the byte array.
If you read file from image you can get like this and pass it to the websocket.
var arr = File(path).inputStream().use { it.readBytes() }
Downside of doing this is , if image size is higher it may not work as expected. And if your websocket sends it to multiple listening clients, it will be quite overload and leads to some delay while sending additional data with file byte array.
Another best approach is to upload image to you sever using http multipart upload(Without socket) and send the image url to server. So url can be sent to clients listening to the particular socket. So the image data can be loaded in client only when required.
If you send byte array in webssocket for big image, the particular websocket response size will be higher than sending the image with image url.
Recommended approach will be method 2 mostly , except some specific use cases.

Working of S3 file download

To download a file from S3 using java SDK, we need to do the following ->
Note- Multipart download is off.
S3Object s3Object = s3.getObject(getObjectRequest);
S3ObjectInputStream s3ObjectInputStream = s3Object.getObjectContent();
//Write to a file from this stream
When we make a getObject call, the SDK does a GET call on that object.
This call returns just the headers of the response.
When we actually start reading from the s3ObjectInputStream, we get the response body.
But this all is one REST call.
So, I was confused why the call returned only the headers first.
And how did S3 know when to start sending in the response body?
We are making only one call, so how are we notifying S3 that we have now started reading from the s3ObjectInputStream.
Where is the actual file stored till we read it from the stream ?
S3 starts sending the response body immediately.
You just haven't started reading it from the network.
getObject
Be extremely careful when using this method; the returned Amazon S3 object contains a direct stream of data from the HTTP connection. The underlying HTTP connection cannot be reused until the user finishes reading the data and closes the stream.
https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#getObject-com.amazonaws.services.s3.model.GetObjectRequest-
A small amount has been buffered, but the object isn't being stored anywhere. The network connection is stalled.
If you were to start a request and wait long enough before reading it, S3 would eventually detect the connection as stalled, give up, and close the connection.
In practice, it's easy to separate HTTP headers from body in a stream, because the boundary between them is always exactly \r\n\r\n. This 4 byte sequence is invalid within the headers, and mandatory after the headers, so the SDK simply stops extracting headers at this point in the response from S3 and builds and returns the response object, from which you can read the body from the stream from the network.

GCM response results has more items than request registration_ids

We send such payload into GCM server
{"data":{"title":"Unlimited Music Ringtones for 24hrs!","p":"5;"},"registration_ids":["APA91bF2U2KaLF173wyqUWfyxKw_xJI4fW22MKRUuoG3E6uubO-a4F9_SS0byscd5YwbbQZsgCsuxmI_IYINZOGRonMH64hZrhDqeqa0a5ixrnhPvcLGGIrIm-J624TCwZFtVktPypyr"],"time_to_live":43200}
But in response we get 9 result items
{"multicast_id":6634278235585666161,"success":1,"failure":8,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1443085201594600%341e1321f9fd7ecd"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"}]}
Issue reproduced from time to time. This is undefined behaviour? How to determine which response it corresponding to register_id?
P.S. We used persistent connection

Is there a way to add header to apache response on how long it took to retrieve a resource?

Is there a module or a built-in function in apache which I can use/activate to send information how long it took to retrieve/process a resource?
For example the resource http://dom.net/resource is accessed. The response header will include the total time it took to wait for the resource to be ready before it gets sent back to the client.
Apache doesn't really 'wait' until the resource is ready before sending the response back to you - it streams data back to the client as and when it receives it.
Depending on what you're interested in measuring, you could record the time taken for the client to receive the first byte/last byte back from Apache, or measure the time taken for Apache to receive the first byte from the (remote?) resource like so. The time taken for Apache to receive the entire response back from the remote resource is not something you can send in the headers, as the headers will have been sent to the client before the remote response is fully received. This information could trivially be written to the Apache logs, however.

SOAP <Body> ...stream... </Body>

I'm working on creating a REST service that contacts a SOAP service that already exists. I'm trying to figure out what a certain SOAP response is sending back, but when I log the raw xml it is saying the body is simple ...stream... Does this mean a stream is being passed back or the actual string "...stream..."
The actual stream is being sent, not the string "...stream...". Since many streams can only be read once, WCF won't consume it to log the message, otherwise it would not be able to send it to the other party (or in the incoming message case, to deliver it to the application)