I am working on image upload functionality on Android, I am using these two libraries: https://github.com/natario1/CameraView
https://github.com/gotev/android-upload-service
So, according to CameraView library I can get my picture like that:
mCameraView.addCameraListener(new CameraListener() {
@Override
public void onPictureTaken(byte[] jpeg) {
super.onPictureTaken(jpeg);
}
});
So I have my picture as byte array. The question here is how can I upload it to my server via multipart? I have my backend ready to accept file. So I believe I have to convert my byte[] to file?
EDIT 1: Sorry for quite unclear question, the question should be narrowed down to "How to write byte[] to file.
Basically what we need is to just write our byte[] to file. First of all I create placeholder file for that. Here is the code snipped for that taken from official google documentation (https://developer.android.com/training/camera/photobasics#TaskPhotoView)
Then I write my byte[] to that file.
uploadImage method handles upload according to android-upload-service: https://github.com/gotev/android-upload-service