File tree Expand file tree Collapse file tree 3 files changed +13
-55
lines changed Expand file tree Collapse file tree 3 files changed +13
-55
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"rules" : {
3
- ".read" : " auth != null" ,
4
- ".write" : " auth != null"
3
+ ".read" : true ,
4
+ ".write" : false ,
5
+
6
+ "posts" : {
7
+ ".write" : " auth != null" ,
8
+ },
9
+
10
+ "uploads" : {
11
+ ".write" : " auth != null" ,
12
+ }
5
13
}
6
14
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ export class UploadService {
11
11
constructor ( private db : AngularFireDatabase ) { }
12
12
13
13
private basePath :string = '/uploads' ;
14
- private uploadTask : firebase . storage . UploadTask ;
15
14
uploads : FirebaseListObservable < Upload [ ] > ;
16
15
17
16
@@ -34,9 +33,9 @@ export class UploadService {
34
33
// Executes the file uploading to firebase https://firebase.google.com/docs/storage/web/upload-files
35
34
pushUpload ( upload : Upload ) {
36
35
let storageRef = firebase . storage ( ) . ref ( ) ;
37
- this . uploadTask = storageRef . child ( `${ this . basePath } /${ upload . file . name } ` ) . put ( upload . file ) ;
36
+ let uploadTask = storageRef . child ( `${ this . basePath } /${ upload . file . name } ` ) . put ( upload . file ) ;
38
37
39
- this . uploadTask . on ( firebase . storage . TaskEvent . STATE_CHANGED ,
38
+ uploadTask . on ( firebase . storage . TaskEvent . STATE_CHANGED ,
40
39
( snapshot ) => {
41
40
// upload in progress
42
41
upload . progress = ( snapshot . bytesTransferred / snapshot . totalBytes ) * 100
@@ -47,7 +46,7 @@ export class UploadService {
47
46
} ,
48
47
( ) => {
49
48
// upload success
50
- upload . url = this . uploadTask . snapshot . downloadURL
49
+ upload . url = uploadTask . snapshot . downloadURL
51
50
upload . name = upload . file . name
52
51
this . saveFileData ( upload )
53
52
}
You can’t perform that action at this time.
0 commit comments