changed firebase storage folder name. now includes uid's
This commit is contained in:
+9
-3
@@ -129,12 +129,18 @@ class _AddScreenState extends State<AddScreen> {
|
||||
|
||||
Future<String> uploadImageToFirebaseStorage(
|
||||
File imageFile, String collectionName) async {
|
||||
String? userId = FirebaseAuth.instance.currentUser?.uid;
|
||||
if (userId != null) {
|
||||
Reference ref = FirebaseStorage.instance
|
||||
.ref()
|
||||
.child("$collectionName/${DateTime.now().toString()}");
|
||||
.child("$collectionName/$userId/${DateTime.now().toString()}");
|
||||
UploadTask uploadTask = ref.putFile(imageFile);
|
||||
return await (await uploadTask).ref.getDownloadURL();
|
||||
} else {
|
||||
throw Exception('Cannot upload without user ID');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -248,7 +254,8 @@ class _AddScreenState extends State<AddScreen> {
|
||||
? Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
double imageHeight = max(0, constraints.maxHeight - keyboardHeight);
|
||||
double imageHeight =
|
||||
max(0, constraints.maxHeight - keyboardHeight);
|
||||
return Container(
|
||||
height: imageHeight,
|
||||
child: Image.file(_imageFile!),
|
||||
@@ -256,7 +263,6 @@ class _AddScreenState extends State<AddScreen> {
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
: Container(
|
||||
height: 200.0,
|
||||
decoration: BoxDecoration(
|
||||
|
||||
Reference in New Issue
Block a user