Open kashifg4171 opened 4 years ago
The only way i fixed it is by making sure im saving the image to the Cache directory (with path_provider
plugin) calling getExternalStorageDirectory
then setting the following in my xml file (covering all bases)
<external-path name="external" path="." />
<external-files-path name="external_files" path="." />
<cache-path name="cache" path="." />
<external-cache-path name="external_cache" path="." />
<files-path name="files" path="." />
The only i fixed it is by making sure im saving the image to the Cache directory (with
path_provider
plugin) callinggetExternalStorageDirectory
then setting the following in my xml file (covering all bases)<external-path name="external" path="." /> <external-files-path name="external_files" path="." /> <cache-path name="cache" path="." /> <external-cache-path name="external_cache" path="." /> <files-path name="files" path="." />
can you please explain where exactly you called getExternalStorageDirectory
?
In my case i call before i save an image to disk (build my path with it as a save location). In your case you might be loading a file to share.
One thing to note is that you need to pass the absolute file path to shareFile
. This tripped me up for a while.
I'm trying to share a file from AppData using this. It works fine on iOS but gives this error when sharing on Android. Any idea how to share files from AppData?
Another way to handle this would be to save your file in the getExternalStorageDirectory before sharing and pass the absolute path of that. Haven't tried it, but will post back the results.
If anyone has a work around for this please share.
I have a work around of this nature. see issue #27 for details.
Had the same problem, this did the trick for me for iOS and Android devices. Thanks @bretie for the suggestion
var output;
if (Platform.isIOS) {
output = await getTemporaryDirectory();
} else {
output = await getExternalStorageDirectory();
}
final file = File("${output.path}/doc.pdf");
await file.writeAsBytes(<Uint8List> file);
try {
await FlutterShare.shareFile(
title: "Title",
filePath: file.path,
);
} catch (err) {
print(err);
}
getExternalStorageDirectory
can't call getExternalStorageDirectory, can you please explain where did you called that function
On Android (happily avoid platform specific handlings) I can use tmpDir = await getTemporaryDirectory()
and File('${tmpDir.path}/kapitel.json')
as well with only this rule
<cache-path name="cache" path="." />
The share dialogue opens and the file sharing works, despite the error log messages:
Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://de.someapp.provider/cache/kapitel.json from pid=20044, uid=1000 requires the provider be exported, or grantUriPermission()
On Android (happily avoid platform specific handlings) I can use
tmpDir = await getTemporaryDirectory()
andFile('${tmpDir.path}/kapitel.json')
as well with only this rule<cache-path name="cache" path="." />
The share dialogue opens and the file sharing works, despite the error log messages:Writing exception to parcel java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://de.someapp.provider/cache/kapitel.json from pid=20044, uid=1000 requires the provider be exported, or grantUriPermission()
I have the same case, but the log with the exception seems to be a problem to me
PlatformException(Failed to find configured root that contains /file:/storage/emulated/0/project/1590844068701.png, null, null)
I'm facing this exception while sharing image file. I had added path provider code in AndroidMinifest.xml file, make new file provider_path.xml in src/xml/...
Any solution please.