0

I am getting the image URL from the backend as a string URL and now I need to send it again to the server, I am getting an error while converting it to multipart and Uri

            File file = null;
            file = new File(Environment.getExternalStorageDirectory() + File.separator + "Photo1");
            file.createNewFile();


            InputStream image_stream = getContentResolver().openInputStream(myUri1);
            Bitmap bitmap= BitmapFactory.decodeStream(image_stream );



            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG, 100 , bos); // YOU can also save it in JPEG
            byte[] bitmapdata = bos.toByteArray();

            FileOutputStream fos = new FileOutputStream(file);
            fos.write(bitmapdata);
            fos.flush();
            fos.close();

            RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
            parts1 =MultipartBody.Part.createFormData("Photo1", file.getName(), requestBody);
            Log.d("@@parts1", String.valueOf(parts1));

        } catch (IOException e) {
            e.printStackTrace();
            Log.d("@@IOException", e.getMessage());
        }

I am getting an error

D/@@IOException: No content provider: http://anothercz.yilstaging.com/writable/uploads/20210107/1610027045_73aae04fa7f668e42a12.png

please help me how to resolve it, I would Appreciate every answer

bugfreerammohan
  • 1,471
  • 1
  • 7
  • 22

0 Answers0