Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uri imageUri = Uri.fromFile(new File(fileName));
- Map<String, RequestBody> map = new HashMap<>();
- if (imageUri != null) {
- File file = new File(imageUri.getPath());
- RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
- map.put("file"; filename="" + file.getName(), fileBody);
- }
- Call<UploadResponse> call = FotomateClient.getFotomateAPI().upload(authorization, map);
- call.enqueue(new Callback<UploadResponse>() {
- @Override
- public void onResponse(Response<UploadResponse> response) {
- if (response != null)
- if (response.body() != null)
- if (response.body().getCode() != null)
- System.out.println(response.body().getCode());
- pd.dismiss();
- if (response.body().isSuccess()) {
- postCart("Bearer " + fm.getAccessToken(), response.body().getCode(), qty);
- dbHelper.deleteImage(id);
- }
- }
- @Override
- public void onFailure(Throwable t) {
- t.printStackTrace();
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement