What I came with is the following:
- for the picture
fis is an inputStream based on the FileDescriptor like
FileInputStream fileInputStream = new FileInputStream(fileDescriptor);
then i read the inputStream in order to get a byteArray
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] result = null;
try {
byte[] input = new byte[fis.available()];
int read;
while ((read = fis.read(input)) != -1) {
out.write(input, 0, read);
}
result = out.toByteArray();
fis.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
after i create a Requestbody as usual, I pass it to retrofit with a special a post multipart method using a special part value as
... , @Nullable @Part("picture\"; filename=\"picture\" ") RequestBody picture ...
That was really hard to find but since retrofit is still in beta it changes a lot and lacks documentation, hope this helps