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 88
99import Foundation
1010
11- struct Config {
11+ class Config {
1212 let apiKey : String
1313 let security : Security ?
14+ var currentUploaders : [ Uploader ] = [ ]
15+
16+ init ( apiKey: String , security: Security ? = nil ) {
17+ self . apiKey = apiKey
18+ self . security = security
19+ }
1420}
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ private extension MultipartUpload {
122122 func upload( ) {
123123 guard let uploadables = uploadables else { return }
124124
125+ config. currentUploaders. append ( self )
125126 state = . inProgress
126127
127128 var results : [ JSONResponse ] = [ ]
@@ -189,6 +190,8 @@ private extension MultipartUpload {
189190 state = . completed
190191 }
191192
193+ config. currentUploaders. removeAll { $0 == self }
194+
192195 queue. async {
193196 self . completionHandler ? ( results)
194197 self . completionHandler = nil
Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ public extension Client {
4646
4747 /// A `Security` object. `nil` by default.
4848 @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 }
4955}
5056
5157// MARK: - Public Functions
You can’t perform that action at this time.
0 commit comments