Skip to content

Application/octet-stream is set as mediaType when uploading json file payload using form parameters instead of application/json #4834

@tejas-ambekar

Description

@tejas-ambekar

I am using jersey implementation for creating a REST service and trying to upload .json file to the server using form parameters. I am creating a FileDataBodyPart object and passing it to object of FormDataMultiPart.

FileDataBodyPart fileBodyPart = new FileDataBodyPart(name, file); form.bodyPart(fileBodyPart);

The default MediaType that is getting set here is application/octet-stream. I looked at jersey library code, it internally "decides" which mediatype to set. If the file type is not in the list of CommonMediaTypes then it sets it as octect-stream.

public static MediaType getMediaTypeFromFileName(final String fileName) {

The above URL points to the jersey code which lists available mediatypes. application/json is not in the list of supported formats.

I wanted to know if there is a specific reason for not supporting the json format by jersey library? Or The support for application/json is added in more recent versions of jersey for multipart file upload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions