You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing my Flutter App which requires users to upload certain images to Firebase. Everything is working flawlessly for authentication of users and storing images to Firebase storage. In the part when user is required to upload a picture with a description from his phone all I get is picture in my storage part of Firebase but no description and other metadata in my database.
I checked database rules and they are public and working fine.
This is the current code for image upload part that is working fine:
void uploadStatusImage() async {
if (validateAndSave()) {
final Reference postImageRef =
FirebaseStorage.instance.ref().child("Post Images");
var timeKey = new DateTime.now();
final Task uploadTask =
postImageRef.child(timeKey.toString() + ".jpg").putFile(sampleImage);
var ImageUrl = await (await uploadTask).ref.getDownloadURL();
url = ImageUrl.toString();
print("Image URL = " + url);
goToHomePage();
saveToDatabase(url);
}
and this is the database part which is not working:
void saveToDatabase(url) {
var dbTimeKey = new DateTime.now();
var formatDate = new DateFormat('MMM d, yyyy');
var formatTime = new DateFormat('EEEE, hh:mm aa');
String date = formatDate.format(dbTimeKey);
String time = formatTime.format(dbTimeKey);
DatabaseReference ref = FirebaseDatabase.instance.reference();
var data = {
"image": url,
"description": _myValue,
"date": date,
"time": time,
};
ref.child("Posts").push().set(data);
VS code is not giving me any errors and app is working fine in my android emulator. I also tried it on physical device and/or using another network with same results. Any help will be greatly appreciated since I am banging my head with this problem for the last couple of days :(. Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am writing my Flutter App which requires users to upload certain images to Firebase. Everything is working flawlessly for authentication of users and storing images to Firebase storage. In the part when user is required to upload a picture with a description from his phone all I get is picture in my storage part of Firebase but no description and other metadata in my database.
I checked database rules and they are public and working fine.
This is the current code for image upload part that is working fine:
and this is the database part which is not working:
VS code is not giving me any errors and app is working fine in my android emulator. I also tried it on physical device and/or using another network with same results. Any help will be greatly appreciated since I am banging my head with this problem for the last couple of days :(. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions