Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter web application download failed - path = Something went wrong, please report the issue https://www.github.com/incrediblezayed/file_saver/issues #51

Open
techttiru opened this issue Oct 16, 2022 · 6 comments

Comments

@techttiru
Copy link

Hi,

I tried this package to download the pdf file in flutter web application using the below code and its working fine if i run this web application in localhost.

  final pdfData =
      await _generatePdf(eventdata, eventAttendeeEntry, typeOfReceipt);
  await Printing.layoutPdf(onLayout: (format) => pdfData);

  MimeType type = MimeType.PDF;
  String path = await FileSaver.instance.saveFile(
      'print_receipt_${eventAttendeeEntry.eventAttendeeEntryId}_${eventAttendeeEntry.eventAttendeeEntryPrintReceiptId}',
      pdfData,
      "pdf",
      mimeType: type);
  print('path = $path');

But if i deploy in server (firebase hosting) and then if i try then i get the below error. any idea? anything blocking in server?

path = Something went wrong, please report the issue https://www.github.com/incrediblezayed/file_saver/issues

appreciate your response!

@ranvirsahota
Copy link

I am also getting in this issue works fine localhost but doesnt work on the web code is similar to yours:
class PdfApi { static saveDocument({ required String name, required Document pdf, }) async { Uint8List pdfInBytes = await pdf.save(); await FileSaver.instance .saveFile(name, pdfInBytes, '.pdf', mimeType: MimeType.PDF); } }

In need of a solution

@incrediblezayed
Copy link
Owner

incrediblezayed commented Nov 6, 2022

I'll get the solution asap, but I'm on vacation for 10 days unfortunately, on November, I'll bring the solution

@ranvirsahota
Copy link

ranvirsahota commented Nov 9, 2022

oh sorry forgot to update this i did find a solution to this the code i used came cakked cross_file, link: https://pub.dev/packages/cross_file
Should note currently does not work on safari
The code is used is here:

      String fileName =
          '${event.invoice.projectNumber}-${event.invoice.invoiceNumber} Invoice.pdf';
      Uint8List fileData = await pdf.save();
      const String mimeType = 'application/pdf';
      final XFile pdfFile =
          XFile.fromData(fileData, mimeType: mimeType, name: fileName);
      await pdfFile.saveTo(fileName);

@incrediblezayed
Copy link
Owner

Hi @ranvirsahota, please test the latest updates and let me know

@NeariX67
Copy link

I'm receiving this error as well. But why does saveFile() return an error string instead of throwing an exception???

@tusharbhambere
Copy link

Getting same issue in latest version file_saver: ^0.2.9
Flutter (Channel stable, 3.16.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants