Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda