|
12 | 12 | totalBytes: storageSnapshot.totalBytes |
13 | 13 | }; |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | function _$put(storageRef, file, $digestFn) { |
17 | 17 | var task = storageRef.put(file); |
18 | 18 |
|
|
22 | 22 | $digestFn(function () { |
23 | 23 | callback.apply(null, [unwrapStorageSnapshot(task.snapshot)]); |
24 | 24 | }); |
25 | | - return true; |
26 | | - }, function () {}, function () {}); |
| 25 | + }); |
27 | 26 | }, |
28 | 27 | $error: function $error(callback) { |
29 | 28 | task.on('state_changed', function () {}, function (err) { |
30 | 29 | $digestFn(function () { |
31 | 30 | callback.apply(null, [err]); |
32 | 31 | }); |
33 | | - return true; |
34 | | - }, function () {}); |
| 32 | + }); |
35 | 33 | }, |
36 | 34 | $complete: function $complete(callback) { |
37 | 35 | task.on('state_changed', function () {}, function () {}, function () { |
38 | 36 | $digestFn(function () { |
39 | 37 | callback.apply(null, [unwrapStorageSnapshot(task.snapshot)]); |
40 | 38 | }); |
41 | | - return true; |
42 | 39 | }); |
43 | 40 | }, |
44 | | - $cancel: function $cancel() { |
45 | | - return task.cancel(); |
46 | | - }, |
47 | | - $resume: function $resume() { |
48 | | - return task.resume(); |
49 | | - }, |
50 | | - $pause: function $pause() { |
51 | | - return task.pause(); |
52 | | - }, |
53 | | - then: function then() { |
54 | | - return task.then(); |
55 | | - }, |
56 | | - catch: function _catch() { |
57 | | - return task.catch(); |
58 | | - }, |
59 | | - _task: function _task() { |
60 | | - return task; |
61 | | - } |
| 41 | + $cancel: task.cancel, |
| 42 | + $resume: task.resume, |
| 43 | + $pause: task.pause, |
| 44 | + then: task.then, |
| 45 | + catch: task.catch, |
| 46 | + _task: task |
62 | 47 | }; |
63 | 48 | } |
64 | 49 |
|
65 | | - function _$getDownloadURL(storageRef, $q) { |
66 | | - return $q.when(storageRef.getDownloadURL()); |
67 | | - } |
68 | | - |
69 | 50 | function isStorageRef(value) { |
70 | 51 | value = value || {}; |
71 | 52 | return typeof value.put === 'function'; |
|
77 | 58 | } |
78 | 59 | } |
79 | 60 |
|
80 | | - function _$delete(storageRef, $q) { |
81 | | - return $q.when(storageRef.delete()); |
82 | | - } |
83 | | - |
84 | | - function _$getMetadata(storageRef, $q) { |
85 | | - return $q.when(storageRef.getMetadata()); |
86 | | - } |
87 | | - |
88 | | - function _$updateMetadata(storageRef, object, $q) { |
89 | | - return $q.when(storageRef.updateMetadata(object)); |
90 | | - } |
91 | | - |
92 | 61 | function FirebaseStorage($firebaseUtils, $q) { |
93 | 62 |
|
94 | 63 | var Storage = function Storage(storageRef) { |
95 | 64 | _assertStorageRef(storageRef); |
96 | 65 | return { |
97 | 66 | $put: function $put(file) { |
98 | | - return Storage.utils._$put(storageRef, file, $firebaseUtils.compile, $q); |
| 67 | + return Storage.utils._$put(storageRef, file, $firebaseUtils.compile); |
99 | 68 | }, |
100 | 69 | $getDownloadURL: function $getDownloadURL() { |
101 | | - return Storage.utils._$getDownloadURL(storageRef, $q); |
| 70 | + return $q.when(storageRef.getDownloadURL()); |
102 | 71 | }, |
103 | 72 | $delete: function $delete() { |
104 | | - return Storage.utils._$delete(storageRef, $q); |
| 73 | + return $q.when(storageRef.delete()); |
105 | 74 | }, |
106 | 75 | $getMetadata: function $getMetadata() { |
107 | | - return Storage.utils._$getMetadata(storageRef, $q); |
| 76 | + return $q.when(storageRef.getMetadata()); |
108 | 77 | }, |
109 | 78 | $updateMetadata: function $updateMetadata(object) { |
110 | | - return Storage.utils._$updateMetadata(storageRef, object, $q); |
| 79 | + return $q.when(storageRef.updateMetadata(object)); |
111 | 80 | } |
112 | 81 | }; |
113 | 82 | }; |
114 | 83 |
|
115 | 84 | Storage.utils = { |
116 | 85 | _unwrapStorageSnapshot: unwrapStorageSnapshot, |
117 | 86 | _$put: _$put, |
118 | | - _$getDownloadURL: _$getDownloadURL, |
119 | 87 | _isStorageRef: isStorageRef, |
120 | | - _assertStorageRef: _assertStorageRef, |
121 | | - _$delete: _$delete, |
122 | | - _$getMetadata: _$getMetadata, |
123 | | - _$updateMetadata: _$updateMetadata |
124 | | - }; |
125 | | - |
| 88 | + _assertStorageRef: _assertStorageRef |
| 89 | + }; |
| 90 | + |
126 | 91 | return Storage; |
127 | | - } |
| 92 | + } |
128 | 93 |
|
129 | 94 | angular.module('firebase.storage') |
130 | 95 | .factory('$firebaseStorage', ["$firebaseUtils", "$q", FirebaseStorage]); |
|
0 commit comments