aboutsummaryrefslogtreecommitdiff
path: root/lib/firebase/storage.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/firebase/storage.dart')
-rw-r--r--lib/firebase/storage.dart16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/firebase/storage.dart b/lib/firebase/storage.dart
new file mode 100644
index 0000000..3e0c629
--- /dev/null
+++ b/lib/firebase/storage.dart
@@ -0,0 +1,16 @@
+import 'dart:io';
+
+import 'package:firebase_storage/firebase_storage.dart';
+import 'package:path/path.dart';
+
+class Storage {
+ final FirebaseStorage _storage = FirebaseStorage.instance;
+
+ Future<String> uploadAvatar(String userId, File file) async {
+ String filename = basename(file.path);
+ Reference ref = _storage.ref().child(userId).child(filename);
+ UploadTask task = ref.putFile(file);
+ await task.whenComplete(() => {});
+ return await ref.getDownloadURL();
+ }
+}