uploadPhoto method

Future<String> uploadPhoto(
  1. File imageFile
)

Uploads an image file to Firebase Storage and returns its public URL.

The image is saved under the path: Users/{userId}/diary_photos/{timestamp}.jpg

Example usage:

final url = await storageService.uploadPhoto(File('path/to/image.jpg'));

This method will be used in the future to attach photos to diary entries.

Implementation

Future<String> uploadPhoto(File imageFile) async {
  final ref = _storage
      .ref()
      .child('Users/$userId/diary_photos/${DateTime.now().millisecondsSinceEpoch}.jpg');

  final uploadTask = await ref.putFile(imageFile);
  return await uploadTask.ref.getDownloadURL();
}