Guest User

Untitled

a guest
Aug 14th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. @Multipart
  2. @POST("index.php")
  3. Call<ResponseModel> uploadImage(@Part("json_field") String description, @Part("image") RequestBody image);
  4.  
  5. if (Build.VERSION.SDK_INT <=19){
  6. Intent intent = new Intent();
  7. intent.setType("image/jpeg");
  8. intent.setAction(Intent.ACTION_GET_CONTENT);
  9. startActivityForResult(Intent.createChooser(intent, "Выбор изоброжения"),100);
  10. } else {
  11. Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
  12. intent.addCategory(Intent.CATEGORY_OPENABLE);
  13. intent.setType("image/*");
  14. startActivityForResult(intent, 100);
  15. }
  16.  
  17. @Override
  18. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  19. super.onActivityResult(requestCode, resultCode, data);
  20. if (requestCode == 100 && resultCode == RESULT_OK){
  21. Uri imageUri = data.getData();
  22. File file = new File(String.valueOf(imageUri));
  23.  
  24.  
  25. RequestBody requestFile = RequestBody.create(imageType, file);
  26.  
  27. uploadData(requestFile);
  28. }
  29. }
  30.  
  31. /content:/media/external/images/media/31037: open failed: ENOENT (No such file or directory)
Add Comment
Please, Sign In to add comment