marinofaggiana před 4 roky
rodič
revize
98ec57120f

+ 1 - 1
File Provider Extension/FileProviderExtension.swift

@@ -226,7 +226,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 fileProviderData.shared.fileProviderManager.register(task!, forItemWithIdentifier: NSFileProviderItemIdentifier(identifier.rawValue)) { (error) in }
             }
             
-        }) { (account, etag, date, length, error, errorCode, errorDescription) in
+        }) { (account, etag, date, length, allHeaderFields, error, errorCode, errorDescription) in
             
             self.outstandingSessionTasks.removeValue(forKey: url)
             guard var metadata = fileProviderUtility.shared.getTableMetadataFromItemIdentifier(identifier) else {

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -2767,7 +2767,7 @@
 			repositoryURL = "https://github.com/nextcloud/ios-communication-library/";
 			requirement = {
 				kind = exactVersion;
-				version = 0.82.0;
+				version = 0.83.0;
 			};
 		};
 		F7C4D88B2534887E00C142DA /* XCRemoteSwiftPackageReference "Parchment" */ = {

+ 2 - 2
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -15,8 +15,8 @@
         "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "9a9c1fdaf4cda70dc3502f5fa24d4e9f04949add",
-          "version": "0.82.0"
+          "revision": "b7411d3fbacff62276d597b136da97217eefb86a",
+          "version": "0.83.0"
         }
       },
       {

+ 1 - 1
Share/ShareViewController.m

@@ -274,7 +274,7 @@
         
         [[NCCommunication shared] uploadWithServerUrlFileName:fileNameServer fileNameLocalPath:fileNameLocal dateCreationFile:nil dateModificationFile:nil customUserAgent:nil addCustomHeaders:nil progressHandler:^(NSProgress * progress) {
             [self.hud progress:progress.fractionCompleted];
-        } completionHandler:^(NSString *account, NSString *ocId, NSString *etag, NSDate *date, int64_t size, NSInteger errorCode, NSString *errorDescription) {
+        } completionHandler:^(NSString *account, NSString *ocId, NSString *etag, NSDate *date, int64_t size, NSDictionary *allHeaderFields, NSInteger errorCode, NSString *errorDescription) {
             [self.hud hideHud];
             [self.filesName removeObject:fileName];
            

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -388,7 +388,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
                 
             }, progressHandler: { (_) in
                 
-            }) { (account, etag, date, lenght, error, errorCode, errorDescription) in
+            }) { (account, etag, date, lenght, allHeaderFields, error, errorCode, errorDescription) in
                 
                 if account == self.appDelegate.account && errorCode == 0 {
                     

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -496,7 +496,7 @@ import NCCommunication
             
         }, progressHandler: { (_) in
             
-        }) { (account, etag, date, lenght, error, errorCode, errorDescription) in
+        }) { (account, etag, date, lenght, allHeaderFields, error, errorCode, errorDescription) in
             
             if errorCode == 0 && account == self.appDelegate.account {
                 self.collectionView.reloadItems(at: [indexPath])

+ 2 - 2
iOSClient/Networking/NCNetworking.swift

@@ -259,7 +259,7 @@ import Queuer
             
             NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, object: nil, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":metadata.serverUrl, "status":NSNumber(value: k_metadataStatusInDownload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
             
-        }) { (account, etag, date, length, error, errorCode, errorDescription) in
+        }) { (account, etag, date, length, allHeaderFields, error, errorCode, errorDescription) in
                        
             if error?.isExplicitlyCancelledError ?? false {
                             
@@ -396,7 +396,7 @@ import Queuer
             
             NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":metadata.serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
             
-        }) { (account, ocId, etag, date, size, error, errorCode, errorDescription) in
+        }) { (account, ocId, etag, date, size, allHeaderFields, error, errorCode, errorDescription) in
          
             self.uploadRequest[fileNameLocalPath] = nil
             self.uploadComplete(fileName: metadata.fileName, serverUrl: metadata.serverUrl, ocId: ocId, etag: etag, date: date, size: size, description: description, task: task!, errorCode: errorCode, errorDescription: errorDescription)

+ 1 - 1
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -275,7 +275,7 @@ import Alamofire
                     
                     NotificationCenter.default.postOnMainThread(name: k_notificationCenter_progressTask, userInfo: ["account":metadata.account, "ocId":metadata.ocId, "serverUrl":serverUrl, "status":NSNumber(value: k_metadataStatusInUpload), "progress":NSNumber(value: progress.fractionCompleted), "totalBytes":NSNumber(value: progress.totalUnitCount), "totalBytesExpected":NSNumber(value: progress.completedUnitCount)])
                     
-                }) { (account, ocId, etag, date, size, error, errorCode, errorDescription) in
+                }) { (account, ocId, etag, date, size, allHeaderFields, error, errorCode, errorDescription) in
                 
                     NCNetworking.shared.uploadRequest[fileNameLocalPath] = nil
                     guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(metadata.ocId) else { return }

+ 11 - 0
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -97,6 +97,17 @@ class NCUtilityFileSystem: NSObject {
         catch {}
     }
     
+    @objc func moveFile(atPath: String, toPath: String) {
+
+        do {
+            try FileManager.default.removeItem(atPath: toPath)
+            try FileManager.default.copyItem(atPath: atPath, toPath: toPath)
+            try FileManager.default.removeItem(atPath: atPath)
+        }
+        catch {}
+        
+    }
+    
     @objc func moveFileInBackground(atPath: String, toPath: String) {
         
         DispatchQueue.global().async {

+ 1 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -305,7 +305,7 @@ class NCViewerImage: UIViewController {
                                         
                         self.progressView.progress = Float(progress.fractionCompleted)
                         
-                    }) { (account, etag, date, length, error, errorCode, errorDescription) in
+                    }) { (account, etag, date, length, allHeaderFields, error, errorCode, errorDescription) in
                         
                         self.progressView.progress = 0
                         

+ 25 - 23
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -195,48 +195,50 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
                 
                 if param["MessageName"] as? String == "downloadAs" {
                     if let values = param["Values"] as? Dictionary<AnyHashable,Any> {
-                        guard let type = values["Type"] as? String else {
-                            return
-                        }
-                        guard let urlString = values["URL"] as? String else {
-                            return
-                        }
-                        guard let url = URL(string: urlString) else {
-                            return
-                        }
-                        guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
-                            return
-                        }
-                        
-                        let filename = (components.path as NSString).lastPathComponent
-                        let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + filename
+                        guard let type = values["Type"] as? String else { return }
+                        guard let urlString = values["URL"] as? String else { return }
+                        guard let url = URL(string: urlString) else { return }
+                        let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + metadata.fileNameWithoutExt
                     
-                        if type == "print" {
-                            NCUtility.shared.startActivityIndicator(view: self.view)
-                        }
+                        NCUtility.shared.startActivityIndicator(view: view)
                         
-                        NCCommunication.shared.download(serverUrlFileName: urlString, fileNameLocalPath: fileNameLocalPath, requestHandler: { (_) in
+                        NCCommunication.shared.download(serverUrlFileName: url, fileNameLocalPath: fileNameLocalPath, requestHandler: { (_) in
                             
                         }, progressHandler: { (_) in
                             
-                        }, completionHandler: { (account, etag, date, lenght, error, errorCode, errorDescription) in
+                        }, completionHandler: { (account, etag, date, lenght, allHeaderFields, error, errorCode, errorDescription) in
+                            
+                            NCUtility.shared.stopActivityIndicator()
                             
                             if errorCode == 0 && account == self.metadata.account {
+                                
+                                var item = fileNameLocalPath
+                                
+                                if let allHeaderFields = allHeaderFields {
+                                    if let disposition = allHeaderFields["Content-Disposition"] as? String {
+                                        let components = disposition.components(separatedBy: "filename=")
+                                        if let filename = components.last?.replacingOccurrences(of: "\"", with: "") {
+                                            item = CCUtility.getDirectoryUserData() + "/" + filename
+                                            NCUtilityFileSystem.shared.moveFile(atPath: fileNameLocalPath, toPath: item)
+                                        }
+                                    }
+                                }
+                                
                                 if type == "print" {
-                                    NCUtility.shared.stopActivityIndicator()
+                                    
                                     let pic = UIPrintInteractionController.shared
                                     let printInfo = UIPrintInfo.printInfo()
                                     printInfo.outputType = UIPrintInfo.OutputType.general
                                     printInfo.orientation = UIPrintInfo.Orientation.portrait
                                     printInfo.jobName = "Document"
                                     pic.printInfo = printInfo
-                                    pic.printingItem = URL(fileURLWithPath: fileNameLocalPath)
+                                    pic.printingItem = URL(fileURLWithPath: item)
                                     pic.present(from: CGRect.zero, in: self.view, animated: true, completionHandler: { (pci, completed, error) in
                                         // end.
                                     })
                                 } else {
                                     self.documentInteractionController = UIDocumentInteractionController()
-                                    self.documentInteractionController.url = URL(fileURLWithPath: fileNameLocalPath)
+                                    self.documentInteractionController.url = URL(fileURLWithPath: item)
                                     self.documentInteractionController.presentOptionsMenu(from: self.appDelegate.window.rootViewController!.view.bounds, in: self.appDelegate.window.rootViewController!.view, animated: true)
                                 }
                             } else {