1

I have used filepicker to choose file from internal storage:

Fresult = await FilePicker.platform.pickFiles(
      type: FileType.custom,
      allowedExtensions: ['pdf', 'jpg'],
 PlatformFile file = Fresult.files.first;
      fiLeName=file.name.toString();
      fiLePath=file.path.toString();
    );

and to convert that file suppose a pdf to base64 I used

final bytes = io.File(fiLePath).readAsBytesSync();
String vbase= base64Encode(bytes);

When i print the base64 string which i have received and used an online converter to see if the file is corrupted or not. but fortunately the result is corrupted.

Is there any way to do it? or have I done it wrong? please help me with it

Ananthakrishna
  • 517
  • 5
  • 24
  • 1
    The most likely answer is that when you `print` the base64 string it's being truncated by the log window. You you are only copying the first bit of the base64 into the online converter. It's almost certainly correct, just truncated. – Richard Heap Sep 01 '21 at 20:15
  • Thanks the print shows only truncated values. when I ran in debug mode i catch up with the full base64 string. Really thanks. you just saved the day. @RichardHeap – Ananthakrishna Sep 02 '21 at 05:23

0 Answers0