|
@@ -43,8 +43,9 @@ class NCNetworkingE2EEUpload: NSObject {
|
|
|
let networkingE2EE = NCNetworkingE2EE()
|
|
|
let utilityFileSystem = NCUtilityFileSystem()
|
|
|
let utility = NCUtility()
|
|
|
+ var numChunks: Int = 0
|
|
|
|
|
|
- func upload(metadata: tableMetadata, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> NKError {
|
|
|
+ func upload(metadata: tableMetadata, uploadE2EEDelegate: uploadE2EEDelegate? = nil, hudView: UIView?) async -> NKError {
|
|
|
|
|
|
var metadata = metadata
|
|
|
let ocIdTemp = metadata.ocId
|
|
@@ -129,17 +130,14 @@ class NCNetworkingE2EEUpload: NSObject {
|
|
|
return NKError(errorCode: NCGlobal.shared.errorE2EELock, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
|
|
|
}
|
|
|
|
|
|
- // HUD
|
|
|
+ // HUD ENCRYPTION
|
|
|
//
|
|
|
-#if !EXTENSION
|
|
|
- DispatchQueue.main.async {
|
|
|
- guard let appDelegate = UIApplication.shared.delegate as? AppDelegate, let hudView = appDelegate.window?.rootViewController?.view else {
|
|
|
- return
|
|
|
+ if let hudView {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.hud.textLabel.text = NSLocalizedString("_wait_file_preparation_", comment: "")
|
|
|
+ self.hud.show(in: hudView)
|
|
|
}
|
|
|
- self.hud.textLabel.text = NSLocalizedString("_wait_file_preparation_", comment: "")
|
|
|
- self.hud.show(in: hudView)
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
// SEND NEW METADATA
|
|
|
//
|
|
@@ -152,6 +150,22 @@ class NCNetworkingE2EEUpload: NSObject {
|
|
|
return sendE2eeError
|
|
|
}
|
|
|
|
|
|
+ // HUD CHUNK
|
|
|
+ //
|
|
|
+ if let hudView {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.hud.indicatorView = JGProgressHUDRingIndicatorView()
|
|
|
+ if let indicatorView = self.hud.indicatorView as? JGProgressHUDRingIndicatorView {
|
|
|
+ indicatorView.ringWidth = 1.5
|
|
|
+ }
|
|
|
+ self.hud.tapOnHUDViewBlock = { _ in
|
|
|
+ NotificationCenter.default.postOnMainThread(name: "NextcloudKit.chunkedFile.stop")
|
|
|
+ }
|
|
|
+ self.hud.textLabel.text = NSLocalizedString("_wait_file_preparation_", comment: "")
|
|
|
+ self.hud.detailTextLabel.text = NSLocalizedString("_tap_to_cancel_", comment: "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// UPLOAD
|
|
|
//
|
|
|
let resultsSendFile = await sendFile(metadata: metadata, e2eToken: e2eToken, uploadE2EEDelegate: uploadE2EEDelegate)
|
|
@@ -200,11 +214,12 @@ class NCNetworkingE2EEUpload: NSObject {
|
|
|
private func sendFile(metadata: tableMetadata, e2eToken: String, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> (ocId: String?, etag: String?, date: NSDate?, afError: AFError?, error: NKError) {
|
|
|
|
|
|
if metadata.chunk > 0 {
|
|
|
+
|
|
|
return await withCheckedContinuation({ continuation in
|
|
|
NCNetworking.shared.uploadChunkFile(metadata: metadata, withUploadComplete: false, customHeaders: ["e2e-token": e2eToken]) { num in
|
|
|
-
|
|
|
+ self.numChunks = num
|
|
|
} counterChunk: { counter in
|
|
|
-
|
|
|
+ DispatchQueue.main.async { self.hud.progress = Float(counter) / Float(self.numChunks) }
|
|
|
} start: {
|
|
|
DispatchQueue.main.async { self.hud.dismiss() }
|
|
|
uploadE2EEDelegate?.start()
|