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

Example for editing a file in situ ? #1

Open
paul-hammant opened this issue May 1, 2019 · 4 comments
Open

Example for editing a file in situ ? #1

paul-hammant opened this issue May 1, 2019 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@paul-hammant
Copy link

Say there's a resource foo/bar.txt and it is only a line or two of CR-delimited text. Can a simple Flutter+Dart app show that being GET from the server, then PUT back to the same server after editing?

That's different to a download/upload scenario :)

@timestee
Copy link
Owner

timestee commented May 3, 2019

Actually, there is not so much difference i think. this lib is using in our Flutter App to sync data from remote web storage and local db on mobile device.

// downlad
List<String> uuids = new List<String>();
List<webdav.FileInfo> files = await webDav.ls("/");
for (webdav.FileInfo file in files) {
    if(file.isDict){
      continue;
    }
    // we just use the uuid as file name in debug mode
    uuids.add(file.name.substring(file.name.lastIndexOf("/")));
}
for(String uuid in uuids) {
    String data = await webDav.downloadToBinaryString(uuid);
    // then store the data to local file or db
    // ... 
}

// upload
var dataMap = Map<String, dynamic>();
// dataMap is the data from local db, or from local file
List<int> list = json.encode(dataMap).codeUnits;
webDav.upload(Uint8List.fromList(list), rid);

Do you feel that we need an example? Perhaps the API is pretty much self-explanatory now.

@paul-hammant
Copy link
Author

Fantastic!!!!!

@timestee
Copy link
Owner

timestee commented May 4, 2019

@paul-hammant i am new to dart,so appreciate if you could give me any suggestion or help me to improve it. Test and example are on the way.

@paul-hammant
Copy link
Author

paul-hammant commented May 4, 2019

So how about a Flutter app with a single textfield. The contents of the textfield come from a GET to (say) http://localhost:8000/textfield.txt. When the item is edited, the mini app does a PUT of the same resource back to the same endpoint. That's the smallest DAV using UI I can think about.

There's no such thing as a single-sourcefile flutter app, but the code for the get widget with inline usage of dart-webdav could be shown inlined in the README.

Otherwise the app goes into examples/ in this repo, with it's own README

Here's a tiny server that can handle PUT and be used in testing of the app - https://gist.github.com/fabiand/5628006

@timestee timestee added the enhancement New feature or request label May 9, 2019
@timestee timestee added the help wanted Extra attention is needed label May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants