Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
how to send an image in a webSocket request using postman

I am new to socket.io and want to send images using postman in a WebSocket request. I have searched for it but could not found any reasonable answer. I have attached the SS of my postman request.

Following is the server-side listener code for the socket.io

$socket->on('send-message', function ($data) use ($io, $socket) {

    $validator = Validator::make($data, [
        'token' => 'required',
        'socket_id' => 'required',
        'receiver_id' => 'required',
        'message' => 'required',
        'file' => 'required|file|image'
    ]);

    if ($validator->fails())
        return $io->emit('error', json_encode(['message' => $validator->messages()]));
                    
    return $io->emit('success', json_encode(['message' => 'image uploaded successfully']));

});

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could send the image as binary data frames:

WebSocket .send() method can send either text or binary data. "socket.send(body)" allows body in string or a binary format, including Blob, ArrayBuffer, etc. No settings required: just send it out in any format.

So basically:

WebSocket.send(000100101010000010011100.....)

BUT - a far simpler solution would be to use a Base64 string, as ALL browsers support it natively:

WebSocket.send('data:image/png;base64,iVBORw0KGgoAAAANSUhEU .......')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!