I am trying to send base64 image through the Intent. I've read that if the image is big, I need to put it to the internal storage first and then retrieve it from its path to send it by Intent. The problem is that android is giving me toast like this:
The upload was unsuccessful because it did not contain data.
I need to say that everything is done in my custom WebView where I passed the context. Maybe that's the issue? My API is 21. I put the code here:
 this.webView.setDownloadListener((new DownloadListener() {
                @Override
                public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                        try {
                            if(url != null) {
                                FileOutputStream fos;
                                fos = context.openFileOutput("image.png", Context.MODE_PRIVATE);
                                byte[] decodedStr = Base64.decode(url, Base64.DEFAULT);
                                fos.write(decodedStr);
                                Intent sendIntent = new Intent();
                                sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                sendIntent.setAction(Intent.ACTION_SEND);
                                sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("file://" + context.getFilesDir() + "/chart.png")));
                                sendIntent.setType("image/png");
                                getContext().startActivity(sendIntent);
                                fos.flush();
                                fos.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }                   
            }));
My base64 looks like this:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArgAAAIACAYAAABpWR83AAAgAElEQVR4Xux9B3xU15X+ESBUEEIVgbpAgCq9V9tg3B1jO3FLcUnsuCa2s7v/TeJksym7yaa6pttOcY2Nu8
It is much longer. I just put here a cut version to make my question more readable.
Thanks for your time!
@EDIT
I have the feeling that it is not clear what he wants to achieve. I'm making use of this tutorial: https://developer.android.com/training/sharing/send.html But the thing which is different is base64 image
**@EDIT 2 **
Changed method to putExtra() but now other apps can't read the image
 
     
    