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

Save files in picked directory #6

Open
florian-obernberger opened this issue Jan 6, 2024 · 6 comments
Open

Save files in picked directory #6

florian-obernberger opened this issue Jan 6, 2024 · 6 comments
Assignees
Labels
done The issue is mainly done but may remain open enhancement New feature or request

Comments

@florian-obernberger
Copy link

florian-obernberger commented Jan 6, 2024

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
Copy link
Owner

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.

@chaudharydeepanshu chaudharydeepanshu self-assigned this Jan 7, 2024
@chaudharydeepanshu chaudharydeepanshu added the enhancement New feature or request label Jan 7, 2024
@florian-obernberger
Copy link
Author

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
Copy link
Owner

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.

@chaudharydeepanshu chaudharydeepanshu added the done The issue is mainly done but may remain open label Feb 7, 2024
@florian-obernberger
Copy link
Author

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

@florian-obernberger
Copy link
Author

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done The issue is mainly done but may remain open enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants