Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void buttonUploadCommand() {
- Bitmap bitmap = FileUtils.getBitmapFromImageView(img);
- File file = FileUtils.getImage(bitmap);
- MultipartBody.Part filePart = MultipartBody.Part.createFormData("file", file.getName(), RequestBody.create(MediaType.parse("image/*"), file));
- RequestBody requestFile = RequestBody.create(MediaType.parse("multupart/form-data"),file);
- MultipartBody.Part requestImage = null;
- requestImage = MultipartBody.Part.createFormData("image",file.getName());
- Call<UploadImageResponse> call = App.get().getApiService().uploadImage2(requestImage);
- call.enqueue(new Callback<UploadImageResponse>() {
- @Override
- public void onResponse(Call<UploadImageResponse> call, Response<UploadImageResponse> response) {
- if(response.isSuccessful()){
- System.out.println("Got 200");
- try {
- System.out.println(response.body()); }
- catch (Exception e) {
- e.printStackTrace();
- System.out.println("Got 400"); }
- try {
- System.out.println(response.body());
- } catch (Exception e) {
- e.printStackTrace(); }
- }else{
- System.out.println("Got 400");
- Log.wtf("tag",response+""); } }
- @Override
- public void onFailure(Call<UploadImageResponse> call, Throwable t) {
- System.out.println("Got BADDDD");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement