Skip to content

Content-Type "false" set when file does not have an extension #118

@BernhardBln

Description

@BernhardBln

When you send a file with a filename that does not have an extension, the content type of that part is set to "false", which obviously ends in an error when talking to the server.

The problematic part is this line:

header +=
        '; filename="' + path.basename(options.filename || value.path) + '"' + FormData.LINE_BREAK +
        'Content-Type: ' +  (options.contentType || mime.lookup(options.filename || value.path));

mime.lookup returns false, when it can't determine the content type.

Maybe replace by this?

header +=
        '; filename="' + path.basename(options.filename || value.path) + '"' + FormData.LINE_BREAK +
        'Content-Type: ' +  (options.contentType || mime.lookup(options.filename || value.path)
                          || 'application/octet-stream');

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions