Skip to content

Commit 87b724a

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 72d3d38 + f5ed4a1 commit 87b724a

File tree

4 files changed

+92
-4
lines changed

4 files changed

+92
-4
lines changed

docs/api/storage

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/api/storage.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
# Storage
3+
4+
Firestack mimics the [Web Firebase SDK Storage](https://firebase.google.com/docs/storage/web/start), whilst
5+
providing some iOS and Android specific functionality.
6+
7+
All Storage operations are accessed via `storage()`.
8+
9+
## Uploading files
10+
11+
### Simple
12+
13+
```javascript
14+
firestack.storage()
15+
.ref('/files/1234')
16+
.putFile('/path/to/file/1234')
17+
.then(uploadedFile => {
18+
//success
19+
})
20+
.catch(err => {
21+
//Error
22+
});
23+
```
24+
25+
### Listen to upload state
26+
27+
```javascript
28+
const unsubscribe = firestack.storage()
29+
.ref('/files/1234')
30+
.putFile('/path/to/file/1234')
31+
.on('state_changed', snapshot => {
32+
//Current upload state
33+
}, err => {
34+
//Error
35+
unsubscribe();
36+
}, uploadedFile => {
37+
//Success
38+
unsubscribe();
39+
});
40+
```
41+
42+
## Downloading files
43+
44+
### Simple
45+
46+
```javascript
47+
firestack.storage()
48+
.ref('/files/1234')
49+
.downloadFile('/path/to/save/file')
50+
.then(downloadedFile => {
51+
//success
52+
})
53+
.catch(err => {
54+
//Error
55+
});
56+
```
57+
58+
### Listen to download state
59+
60+
```javascript
61+
const unsubscribe = firestack.storage()
62+
.ref('/files/1234')
63+
.downloadFile('/path/to/save/file')
64+
.on('state_changed', snapshot => {
65+
//Current download state
66+
}, err => {
67+
//Error
68+
unsubscribe();
69+
}, downloadedFile => {
70+
//Success
71+
unsubscribe();
72+
});
73+
```
74+
75+
## TODO
76+
77+
There are a few methods which have not yet been implemented for Storage:
78+
79+
### Reference
80+
- put()
81+
- putString()
82+
83+
### UploadTask
84+
- cancel()
85+
- pause()
86+
- resume()
87+
88+
### DownloadTask
89+
- cancel()
90+
- pause()
91+
- resume()

lib/modules/database/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default class Database extends Base {
192192

193193
if (this.subscriptions[handle] && this.subscriptions[handle][eventName]) {
194194
this.subscriptions[handle][eventName].forEach((cb) => {
195-
cb(new Snapshot(new Reference(this, path.split('/'), modifiersString.split('|')), snapshot), body);
195+
cb(new Snapshot(new Reference(this, path, modifiersString.split('|')), snapshot), body);
196196
});
197197
} else {
198198
FirestackDatabase.off(path, modifiersString, eventName, () => {

lib/modules/storage/reference.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export default class StorageRef extends ReferenceBase {
6666
}
6767

6868
//Additional methods compared to Web API
69-
70-
//TODO: Listeners
7169
/**
7270
* Downloads a reference to the device
7371
* @param {String} filePath Where to store the file

0 commit comments

Comments
 (0)