• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

212
Views
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
}
about 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error