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

299
Visualizações
Dropzone Not Recognising File Or MIME Type Request Header. MVC .NET

I am using Dropzone.js to upload a file with an .msg extension and a MIME type of application/vnd.ms-outlook.

When I select a file with a .msg extension the file type is empty.

This can be fixed by implementing an accept function and setting the file type however, when the request is sent the MIME type is set to application/octet-stream which is the default when the content type is unknown or empty.


Question

How can I set the Content-Type for the file e.g. MyFile.msg in the multipart/form-data; to application/vnd.ms-outlook?


Request

POST www.someurl.com
...
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryMagrF5N9EvrTWyiY
Accept: application/json
X-Requested-With: XMLHttpRequest
...

------WebKitFormBoundaryMagrF5N9EvrTAAA
Content-Disposition: form-data; name="Filename"

MyFile.msg
------WebKitFormBoundaryMagrF5N9EvrTAAA
Content-Disposition: form-data; name="Details"

------WebKitFormBoundaryMagrF5N9EvrTAAA
Content-Disposition: form-data; name="file"; filename="MyFile.msg"
Content-Type: application/octet-stream //NEED TO CHANGE

Dropzone

accept: function (file, done) {

        // file.type = ""

        if (file.name.split('.').pop()=== 'msg') {
            Object.defineProperty(file, 'type', { value: 'application/vnd.ms-outlook' });
        }           

        done();
    }
},
init: function () {

    this.on("sending", function (file, xhr, data) {
            // This sets the Content-type for the request not just the
            // uploaded file i.e. one boundary of multipart/form-data

            // var send = xhr.send;
            // xhr.send = function () {
            //    xhr.setRequestHeader('Content-Type', file.type);                  
            //    send.call(xhr, file);
            // };
        }
}

Controller

[HttpPost]
public ActionResult PostFile(HttpPostedFileBase file)
{
    // file.ContentType is application/octet-stream
}
over 4 years ago · Santiago Trujillo
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
Assistente virtual