Skip to content

Commit 92a26dc

Browse files
authored
add an other file example to README (#410)
* added file example to README * Update README.md
1 parent 7449b31 commit 92a26dc

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Have a look at the example application for a small (non web) example.
825825

826826

827827
```dart
828-
//A short example
828+
//A short example for showing an image from a ParseFileBase
829829
Widget buildImage(ParseFileBase image){
830830
return FutureBuilder<ParseFileBase>(
831831
future: image.download(),
@@ -844,6 +844,23 @@ Widget buildImage(ParseFileBase image){
844844
);
845845
}
846846
```
847+
```dart
848+
//A short example for storing a selected picture
849+
//libraries: image_picker (https://pub.dev/packages/image_picker), image_picker_for_web (https://pub.dev/packages/image_picker_for_web)
850+
PickedFile pickedFile = await ImagePicker().getImage(source: ImageSource.gallery);
851+
ParseFileBase parseFile;
852+
if (kIsWeb) {
853+
//Seems weird, but this lets you get the data from the selected file as an Uint8List very easily.
854+
ParseWebFile file = ParseWebFile(null, name: null, url: pickedFile.path);
855+
await file.download();
856+
parseFile = ParseWebFile(file.file, name: file.name);
857+
} else {
858+
parseFile = ParseFile(File(pickedFile.path));
859+
}
860+
someParseObject.set("image", parseFile);
861+
//This saves the ParseObject as well as all of its children, and the ParseFileBase is such a child.
862+
await someParseObject.save();
863+
```
847864

848865
## Other Features of this library
849866
Main:

0 commit comments

Comments
 (0)