File file = new File(getFilesDir().getAbsolutePath());
if (!file.exists()) {
file.mkdirs();
}
File file1 = new File(file, "photo.png");
FileOutputStream fileOutputStream;
try {
fileOutputStream = new FileOutputStream(file1);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
RequestBody requestBody = RequestBody.create(MediaType.parse("image/*"), file1);
MultipartBody.Part part = MultipartBody.Part.createFormData("file", file1.getName(), requestBody);