Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. Uri imageUri = Uri.fromFile(new File(fileName));
  2.  
  3. Map<String, RequestBody> map = new HashMap<>();
  4. if (imageUri != null) {
  5. File file = new File(imageUri.getPath());
  6. RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
  7. map.put("file"; filename="" + file.getName(), fileBody);
  8. }
  9.  
  10. Call<UploadResponse> call = FotomateClient.getFotomateAPI().upload(authorization, map);
  11. call.enqueue(new Callback<UploadResponse>() {
  12. @Override
  13. public void onResponse(Response<UploadResponse> response) {
  14. if (response != null)
  15. if (response.body() != null)
  16. if (response.body().getCode() != null)
  17. System.out.println(response.body().getCode());
  18. pd.dismiss();
  19. if (response.body().isSuccess()) {
  20. postCart("Bearer " + fm.getAccessToken(), response.body().getCode(), qty);
  21. dbHelper.deleteImage(id);
  22.  
  23. }
  24. }
  25.  
  26. @Override
  27. public void onFailure(Throwable t) {
  28. t.printStackTrace();
  29. }
  30. });
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement