Canvas2ImagePlugin icon indicating copy to clipboard operation
Canvas2ImagePlugin copied to clipboard

How to get the file name?

Open MestreKarin opened this issue 4 years ago • 2 comments

How can I get the full path of the image (including it's name)? After the user save the image, I display that window for him to share, but I need the full file path.

MestreKarin avatar Aug 13 '20 18:08 MestreKarin

Ok, I read the source and done two modifications:

In savePhoto() function, I created a string variable imageName after imageUri variable, then, on callbackContext.success call, I pass the path with file name.

private void savePhoto() {
	Uri imageUri = null;
	String imageName = "ep_" + System.currentTimeMillis() + (this.format.equals("png") ? ".png" : ".jpg");
	
	//...
	//...
	
	callbackContext.success(imageUri.getPath() + "/" + imageName);
}

In my app, I receive something like this: /external/images/media/1539/ep_1597346437716.png.

The Problem

Even though the share window recognize as image (see image below), no matter what app I choose, I doesn't accept it. With gmail, it says "cannot attach file". Whatsapp says "The file format is not supported". This is weird, since I can see and share the image normally if I go to my gallery.

Screenshot_20200813-163225_Android System

I'm using this plugin to share, passing the file path in files property.

MestreKarin avatar Aug 13 '20 19:08 MestreKarin

its probably because of the location. you have to write in a folder that is accessible to all apps.

rodrigograca31 avatar Aug 14 '20 19:08 rodrigograca31