chaudharydeepanshu / pick_or_save

A Flutter file picking and saving package that enables you to pick or save a single file and multiple files.
https://pub.dev/packages/pick_or_save
BSD 3-Clause "New" or "Revised" License
13 stars 7 forks source link

Save files in picked directory #6

Open florian-obernberger opened 10 months ago

florian-obernberger commented 10 months ago

Hey there! First of all thank you for this lovely package! So far it works absolutely flawless!

I just have one question: How can I save files to a persistent directory that the user chose?

I would like to auto-export backup files into the folder and asking the user every time for that would kind off defeat the purpose of auto backups... So: Is there any way to save files to the picked directory? If I overlooked it in the documentation I apologize and thanks in advance for your response!

chaudharydeepanshu commented 10 months ago

Hello, thanks a lot for the sweet words!🌟

Unfortunately, I just noticed that it is missing this functionality. But hey, adding it seems easy, and it's an important feature.

I'll look into it, and if everything goes well, I'll have it ready in a few days.

Thanks a lot for bringing this issue up.

florian-obernberger commented 10 months ago

Thank you so much for your nice reply :D

I'd love to help implement this / similar operations but unfortunately I (as of yet) don't know how android native code works ^^'

If there is anything on the Dart / Flutter side you'd like help with, I'll gladly try my best :)

chaudharydeepanshu commented 9 months ago

Hello @florian-obernberger ,

Sorry for the delayed update; I've been busy with other tasks and forgot about this. But finally, I implemented this in the plugin.

To test it, you can use the GitHub project as a dependency:

  dependencies:
    pick_or_save:
      git:
        url: https://github.com/chaudharydeepanshu/pick_or_save.git

Example dart code:

// Picking Directory
String? pickedDirectoryUri = await PickOrSave().directoryPicker(
  params: DirectoryPickerParams()
);

// Saving to picked directory
List<String>? result = await PickOrSave().fileSaver(
  params: FileSaverParams(
    saveFiles: [
      SaveFileInfo(
          filePath: filePath,
          fileName: "File.png")
    ],
    directoryUri: pickedDirectoryUri,  //<---------- New parameter for saving to the picked directory directly
  )
);
String savedFilePath = result[0];

You can also run the example app to test it: image

I will test it and clean up the old code before publishing it on pub.dev in a few days. So, please feel free to give it a try and let me know your feedback.

Thank you for your patience and support.

florian-obernberger commented 9 months ago

Thank you so much!! I will test it out in the coming test and let you know if any problems arise :)

florian-obernberger commented 9 months ago

So, I finally came around to testing it and I found one bug / issue: Even when called only once the same file is often saved multiple times resulting in not just <filename>.<ext> but also <filename> (1).<ext>, <filename> (2).<ext> and so on. This occurred both in my own implementation as well as your test app.

Is there something I missed? Should I close this issue and create a separate one?

Also thanks again for this amazing plugin!

chaudharydeepanshu commented 9 months ago

Thanks for testing it! Finally got some time to re-work the whole old code and fix all known issues. I'll roll a pre-release by maybe tomorrow!

Also, we will track it here until it's bug-free.