Skip to content

Instantly share code, notes, and snippets.

@MeshkaniMohammad
Created August 7, 2018 16:23
Show Gist options
  • Save MeshkaniMohammad/b42e86668da58174d60d15c784a5d3a5 to your computer and use it in GitHub Desktop.
Save MeshkaniMohammad/b42e86668da58174d60d15c784a5d3a5 to your computer and use it in GitHub Desktop.
var fileName = "fileName.jpeg";
StorageUploadTask putFile =
storage.ref().child("folder/$fileName").putFile(_image);
putFile.future.catchError(onError);
UploadTaskSnapshot uploadSnapshot = await putFile.future;
print("image uploaded");
Map<String, dynamic> pictureData = new Map<String, dynamic>();
pictureData["url"] = uploadSnapshot.downloadUrl.toString();
DocumentReference collectionReference =
Firestore.instance.collection("collection").document(fileName);
await Firestore.instance.runTransaction((transaction) async {
await transaction.set(collectionReference, pictureData);
print("instance created");
}).catchError(onError);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment