esysberlin / esys-flutter-share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
130 stars 147 forks source link

Wrong mimeType when sharing single File #70

Closed DiaconescuCosta closed 4 years ago

DiaconescuCosta commented 4 years ago

Describe the bug So i need to share an image to another application with Flutter, i use your plugin, i use the example from the example page, it works to share the file, the only issue that the Android/Ios simulator and Ios real phone doesn't recognize the extension of the file (mimeType) , it always shares the file as a text not as an image file.

Expected behavior Need to share the file as an image that is actual is, not like a plain text

Screenshots How it works now How should share

Smartphone (please complete the following information):

Additional context

Future<void> _shareImage(int index) async {
    final filename = _imageList[index].split("/")[2];
    try {
      final ByteData bytes = await rootBundle.load(_imageList[index]);
      await Share.file(
          'esys image', 'esys.png', bytes.buffer.asUint8List(), 'image/png',
          text: '$filename');
    } catch (e) {
      print('error: $e');
    }
  }
DiaconescuCosta commented 4 years ago

Found my issue with , if i let the let the optional String Text empty, the plugin shares the file as and image file, example:

final ByteData bytes = await rootBundle.load('assets/images/p1.jpg');
      await Share.file(
          'Preset image', '$filename.jpg', bytes.buffer.asUint8List(), '',
          text: '');

Instead if i write anything in the optional description string "text: 'My optional text.'" when i share i get the file shared like a text like as the original issue.