Skip to content

Commit

Permalink
storage reference methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMusleh committed Jan 10, 2020
1 parent 5564989 commit 1c1f1bb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
39 changes: 18 additions & 21 deletions packages/firebase_storage/firebase_storage/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,24 @@ class _MyHomePageState extends State<MyHomePage> {
List<StorageUploadTask> _tasks = <StorageUploadTask>[];

Future<void> _uploadFile() async {
print('supposed to upload file, calling ref instead');
var response = widget.storage.ref();
print('ref returned :$response');
// final String uuid = Uuid().v1();
// final Directory systemTempDir = Directory.systemTemp;
// final File file = await File('${systemTempDir.path}/foo$uuid.txt').create();
// await file.writeAsString(kTestString);
// assert(await file.readAsString() == kTestString);
// final StorageReference ref =
// widget.storage.ref().child('text').child('foo$uuid.txt');
// final StorageUploadTask uploadTask = ref.putFile(
// file,
// StorageMetadata(
// contentLanguage: 'en',
// customMetadata: <String, String>{'activity': 'test'},
// ),
// );

// setState(() {
// _tasks.add(uploadTask);
// });
final String uuid = Uuid().v1();
final Directory systemTempDir = Directory.systemTemp;
final File file = await File('${systemTempDir.path}/foo$uuid.txt').create();
await file.writeAsString(kTestString);
assert(await file.readAsString() == kTestString);
final StorageReference ref =
widget.storage.ref().child('text').child('foo$uuid.txt');
final StorageUploadTask uploadTask = ref.putFile(
file,
StorageMetadata(
contentLanguage: 'en',
customMetadata: <String, String>{'activity': 'test'},
),
);

setState(() {
_tasks.add(uploadTask);
});
}

Future<void> _downloadFile(StorageReference ref) async {
Expand Down
22 changes: 22 additions & 0 deletions packages/firebase_storage/firebase_storage/example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
<title>example</title>
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-storage.js"></script>

<script>
// name: 'test',
// options: FirebaseOptions(
// googleAppID: Platform.isIOS
// ? '1:159623150305:ios:4a213ef3dbd8997b'
// : '1:159623150305:android:ef48439a0cc0263d',
// gcmSenderID: '159623150305',
// apiKey: 'AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg',
// projectID: 'flutter-firebase-plugins',
// ),
// );
firebase.initializeApp({
apiKey: "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg",
projectId: "flutter-firebase-plugins",
storageBucket: "flutter-firebase-plugins.appspot.com"
});
</script>

<script src="main.dart.js" type="application/javascript"></script>

</body>
</html>

0 comments on commit 1c1f1bb

Please sign in to comment.