From 59e2296b7a5f50ae57c751a9a7bf5f84b3f1a03e Mon Sep 17 00:00:00 2001 From: maaeps Date: Sun, 9 Aug 2020 17:45:34 +0200 Subject: [PATCH 1/2] added file example to README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c57a1d8a8..2b40c2f61 100644 --- a/README.md +++ b/README.md @@ -825,7 +825,7 @@ Have a look at the example application for a small (non web) example. ```dart -//A short example +//A short example for showing an image from a ParseFileBase Widget buildImage(ParseFileBase image){ return FutureBuilder( future: image.download(), @@ -844,6 +844,23 @@ Widget buildImage(ParseFileBase image){ ); } ``` +```dart +//A short example for storing a selected picture +//libraries: image_picker, image_picker_for_web +PickedFile pickedFile = await ImagePicker().getImage(source: ImageSource.gallery); +ParseFileBase parseFile; +if (kIsWeb) { + //Seems weird but this lets you get the data from the selected file as an Uint8List very easily. + ParseWebFile file = ParseWebFile(null, name: null, url: pickedFile.path); + await file.download(); + parseFile = ParseWebFile(file.file, name: file.name); +} else { + parseFile = ParseFile(File(pickedFile.path)); +} +someParseObject.set("image", parseFile); +//This saves the ParseObject as well as all of its children, and the ParseFileBase is such a child. +await someParseObject.save(); +``` ## Other Features of this library Main: From c0418ee97805c6ea5799b90841fb0b218eabae6a Mon Sep 17 00:00:00 2001 From: maaeps Date: Sun, 9 Aug 2020 17:47:35 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b40c2f61..f029e43e5 100644 --- a/README.md +++ b/README.md @@ -846,11 +846,11 @@ Widget buildImage(ParseFileBase image){ ``` ```dart //A short example for storing a selected picture -//libraries: image_picker, image_picker_for_web +//libraries: image_picker (https://pub.dev/packages/image_picker), image_picker_for_web (https://pub.dev/packages/image_picker_for_web) PickedFile pickedFile = await ImagePicker().getImage(source: ImageSource.gallery); ParseFileBase parseFile; if (kIsWeb) { - //Seems weird but this lets you get the data from the selected file as an Uint8List very easily. + //Seems weird, but this lets you get the data from the selected file as an Uint8List very easily. ParseWebFile file = ParseWebFile(null, name: null, url: pickedFile.path); await file.download(); parseFile = ParseWebFile(file.file, name: file.name);