Coder Social home page Coder Social logo

document_file_save's Introduction

document_file_save

Save bytes data into Download folder (Android), or show save dialog (iOS). You can save any file types (Ex. .txt, .png, .jpg, .pdf, etc)

Install plugin

add this line into pubspec.yaml

document_file_save: ^1.0.3

Permission

Android

if your project set android target >= Android Q, you don't have to add any permission. Otherwise, Add the following statement in AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

iOS

No permission needed.

Function description

// call function 'saveFile' if you 1 file to save.
void saveFile(Uint8List data, String fileName, String mimeType)

// call function 'saveMultipleFiles' if you have mutiple files to save. iOS will show save dialog only once
void saveMultipleFiles(List<Uint8List> dataList, List<String> fileNameList, List<String> mimeTypeList)

Example usage

import 'package:document_file_save/document_file_save.dart';

//Save multiple files
List<int> textBytes = utf8.encode("Some data");
List<int> textBytes2 = utf8.encode("Another data");
DocumentFileSave.saveMultipleFiles([textBytes, textBytes2], ["text1.txt", "text2.txt"], ["text/plain", "text/plain"]);

//Save single text file
DocumentFileSave.saveFile(textBytes, "my_sample_file.txt", "text/plain");

//Save single pdf file
DocumentFileSave.saveFile(pdfBytes, "my_sample_file.pdf", "appliation/pdf");

//Save single image file
DocumentFileSave.saveFile(imageJPGBytes, "my_sample_file.jpg", "image/jpeg");

document_file_save's People

Contributors

piyapan039285 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

document_file_save's Issues

File Not Saving to Download folder in MI 9i

I'm trying to save the pdf file in the downloads folder, DocumentFileSavePlus.saveFile(pdfBytes, filename,"appliation/pdf") runs successfully without error, but the file is not saved, this issue is only happening in MI phone.

It is Working flawlessly in pixel emulators and Samsung phones including android 13.

Upgrade to Null Safety

Hi :)

Thank you for providing this package! You suceeded, where others did not: I had a lot of trouble writing data files (json) to the download dir on some Android versions. With your package it's working like a charm!

I've just opened a Pull request, that contains the migration to null safety.

I would be super happy, if you would publish a new version. This is the last dependency, I need to update, in order to migrate my project to sound null safety ;)

Thank you!

Kind regards,
Anne

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.