Hi,
I need to upload files to a server endpoint that requires custom headers on individual multipart parts (e.g. X-checksum for integrity verification on each uploaded file). With curl this is straightforward using the ;headers= suffix on -F:
curl -X POST "http://localhost:8080/upload" \
-F 'file=@/path/to/test.md;type=text/plain;headers="X-checksum: some-checksum"'
Unirest's MultipartBody API currently only lets me set Content-Type per part, but there's no way to attach additional headers to a single part.
I can think of two possible solutions:
either: A fluent method on MultipartBody that attaches a header to the most recently added part:
Unirest.post("http://localhost:8080/upload")
.field("file", new File("/path/to/test.md"), "text/plain")
.partHeader("X-checksum", "some-checksum")
.asString();
or: another overload for .field():
Headers partHeaders = new Headers();
partHeaders.add("X-checksum", "some-checksum");
Unirest.post("http://localhost:8080/upload")
.field("file", new File("/path/to/test.md"), "text/plain", partHeaders)
.asString();
It does seem, however, that RFC 7578 §4.8 does not allow the setting of custom headers, but would you consider this feature nonetheless? It is supported by other major HTTP clients like curl.
Thanks!
Hi,
I need to upload files to a server endpoint that requires custom headers on individual multipart parts (e.g. X-checksum for integrity verification on each uploaded file). With curl this is straightforward using the ;headers= suffix on -F:
Unirest's MultipartBody API currently only lets me set Content-Type per part, but there's no way to attach additional headers to a single part.
I can think of two possible solutions:
either: A fluent method on MultipartBody that attaches a header to the most recently added part:
or: another overload for
.field():It does seem, however, that RFC 7578 §4.8 does not allow the setting of custom headers, but would you consider this feature nonetheless? It is supported by other major HTTP clients like curl.
Thanks!