File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import Foundation
10
10
11
- struct Config {
11
+ class Config {
12
12
let apiKey : String
13
13
let security : Security ?
14
+ var currentUploaders : [ Uploader ] = [ ]
15
+
16
+ init ( apiKey: String , security: Security ? = nil ) {
17
+ self . apiKey = apiKey
18
+ self . security = security
19
+ }
14
20
}
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ private extension MultipartUpload {
122
122
func upload( ) {
123
123
guard let uploadables = uploadables else { return }
124
124
125
+ config. currentUploaders. append ( self )
125
126
state = . inProgress
126
127
127
128
var results : [ JSONResponse ] = [ ]
@@ -189,6 +190,8 @@ private extension MultipartUpload {
189
190
state = . completed
190
191
}
191
192
193
+ config. currentUploaders. removeAll { $0 == self }
194
+
192
195
queue. async {
193
196
self . completionHandler ? ( results)
194
197
self . completionHandler = nil
Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ public extension Client {
46
46
47
47
/// A `Security` object. `nil` by default.
48
48
@objc var security : Security ? { config. security }
49
+
50
+ /// Returns an array containing the `Uploader` instances currently running.
51
+ @objc var currentUploaders : [ Uploader ] { config. currentUploaders }
52
+
53
+ /// Returns whether there's at least a single `Uploader` instance currently running.
54
+ @objc var isUploading : Bool { config. currentUploaders. count > 0 }
49
55
}
50
56
51
57
// MARK: - Public Functions
You can’t perform that action at this time.
0 commit comments