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

170
Vistas
How to consume File with a content type of message/rfc822 in my REST API in a MultipartFormData?

In my Vue App I have this file input:

<input type="file" multiple @input="handleFileInput" />

The selected files are passed to my this upload method:

 public async uploadFiles(file: File) {

    [...]
    const formData = new FormData();
    formData.append('fileName', file.name);
    formData.append('file', file);
    [...]
    await axios.post('my-upload-url', formData);    
}

The js log before sending it:

enter image description here

The network log after sending it:

enter image description here

My Resteasy controller answers:

@POST
@Transactional
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadMultipartData(@MultipartForm @Valid MyDto dto) {
 // dto.file -> my file
}

The DTO:

public class MyDto {
    @NotNull
    @FormParam("file")
    @PartType(MediaType.APPLICATION_OCTET_STREAM)
    public InputStream file;
}

When transferring other file types (pdf, png, jpg, mp3, ...) the file is in the InputStream of the DTO as expected. However, when it the file is an .eml file, the InputStream is null.

Update: when renaming the file from text.eml to test.txt, the upload works.

Why?

In other words, how do I consume a File with a content type of message/rfc822 in my REST Api? Do I need a separate method that accepts this specific Media Type?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So this most certainly has to do with how your server handles the uploaded file. application/octet-stream simply represents a generic/unknown binary file. From RFC 2046 § 4.5.1:

The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.

Most apps will try to determine the file mimetype by looking at their file's extension, but it will have trouble determine it if the extension is unknown to them. An eml file is just a text file, which explains why when changing the extension to txt works without problems. The easiest way to verify this by taking a simple txt file and changing its extension to unknown (for example) and try to upload that file.

I have set up an example replicating the exact same scenario and in this case the server has no trouble reading the file contents.

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