2

I'm getting Facebook profile image url, what I'm doing is downloading that image to the memory using

String extension = filePath.substring(filePath.lastIndexOf("."));
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/" + extension);
    values.put(MediaStore.MediaColumns.DATA, filePath);
    context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

and I'm uploading it to the server using Multiparty entity:

MultipartEntity entity = new MultipartEntity();
        if (TextUtils.isEmpty(strProfilePic)) {
            File file = new File(strProfilePic);
            if (file.exists()) {
                FileBody fileBody = new FileBody(file);
                entity.addPart("profile_picture", fileBody);
            }
        }

The problem here is, accessing the Image in gallery I have to set permission which is annoying as user is not actually trying to upload the image so if he deny then image wont be uploaded.

Is there any way I can send an Image to server with out downloading it to the memory

Praneeth
  • 1,260
  • 18
  • 37

0 Answers0