Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda