Skip to content

Uploading file with metadata using unirest js api causing trouble when sending data #132

@mohan491986

Description

@mohan491986

I am need to pass file with metadata and I followed the way mentioned in documentation
Client nodejs-
unirest.post(url)
.auth({user:'username', pass:'pwd'})
.header({'Content-Type': 'multipart/form-data'})
.field('objectMetadata', JSON.Stringify(json obj))
.field("file1", fs.createReadStream("setup.docx"))
.then(function (response) {
console.log(response.body)
});
Server - Java based
public Response uploadFileWithMetadata(ObjectMetadata objectMetadata, MultipartBody multipartBody) {}

In the server user says he see objectMetadata object as null and in multipartBody he sees 2 atts - one for file and other for objectmetadata. Same server works for unirest java and I tweaked the metadata part as below

.field("objectMetadata", params, false, "application/json")

Please let me know if I am missing something in the node based svc call

after retries, I need below snippet java equivalent in nodejs

.field(name, value, file, contentType)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions