alexrintt / shared-storage

Flutter plugin to work with Android external storage.
http://alexrintt.io/shared-storage/
MIT License
53 stars 25 forks source link

Add some way to update/overwrite file contents (e.g `updateFile(...)`) #79

Closed alexrintt closed 2 years ago

alexrintt commented 2 years ago

Feature request

Currently we can't overwrite/update the content of a given file we already have permissions over.

So the request is only to add an API which purpose is to receive a given uri and content or bytes as parameters and overwrite the content.

Sample usage:

final updatedFile = await updateFile(
  targetFile,
  bytes: UintList.fromList('content in bytes'.codeUnits),
  content: '...',
);

This will permit edit only the file contents and not the file mime type.

Useful resources

Originally requested by @jfaltis at #61.

jfaltis commented 2 years ago

I have actually already implemented this feature in the flutter_content_resolver plugin utilizing the Android ContentResolver to write to a URI (https://github.com/espresso3389/flutter_content_resolver/pull/1). Either it could be implemented in the same way for this plugin or use the flutter_content_resolver as a dependency. What do you think?

alexrintt commented 2 years ago

Would be helpful to use you implementation here, seems like it's exactly what we need.

I'll open a PR to add your implementation here, or you can do by yourself if you want, just let me know.

Although I don't see reason to add flutter_content_resolver as dependency:

Also let me know what do you think.

jfaltis commented 2 years ago

I agree with your points on not using the flutter_content_resolver as a dependency. I will open a pull request with the implementation in the upcoming days.

alexrintt commented 2 years ago

Closing since its already implemented by #85.