blob: 3e0c629f7706636b0007a656641a37e3701cc752 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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();
}
}
|