marinofaggiana 4 years ago
parent
commit
7618fa3263

+ 1 - 1
Cartfile.resolved

@@ -18,7 +18,7 @@ github "malcommac/SwiftRichString" "3.7.2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/OpenSSL" "6c7cf839d9c74e5a0b92bbf343e1a33b6f56a277"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
-github "nextcloud/ios-communication-library" "744b1b8e31e508ceda18d0b0f928e8c2bdb637b1"
+github "nextcloud/ios-communication-library" "2ac72a3df0fb6e9e4b03ad963a09ae9e5078b05c"
 github "rechsteiner/Parchment" "v2.4.0"
 github "scenee/FloatingPanel" "v1.7.6"
 github "tilltue/TLPhotoPicker" "2.0.12"

+ 15 - 2
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -661,12 +661,21 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     @objc func pasteFiles(_ notification: Any) {
         
+        var listData: [String] = []
+        
         for item in UIPasteboard.general.items {
             for object in item {
                 let contentType = object.key
                 let data = object.value
+                if data is String {
+                    if listData.contains(data as! String) {
+                        continue
+                    } else {
+                        listData.append(data as! String)
+                    }
+                }
                 let type = NCCommunicationCommon.shared.convertUTItoResultType(fileUTI: contentType as CFString)
-                if type.resultTypeFile != NCCommunicationCommon.typeFile.unknow.rawValue {
+                if type.resultTypeFile != NCCommunicationCommon.typeFile.unknow.rawValue && type.resultExtension != "" {
                     uploadPasteFile(fileName: type.resultFilename, ext: type.resultExtension, contentType: contentType, data: data)
                 }
             }
@@ -675,7 +684,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     
     private func uploadPasteFile(fileName: String, ext: String, contentType: String, data: Any) {
         do {
-            let fileNameView = CCUtility.createFileNameDate(fileName, extension: ext)!
+            let fileNameView = fileName + "_" + CCUtility.getIncrementalNumber() + "." + ext
             let ocId = UUID().uuidString
             let filePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView)!
             
@@ -683,6 +692,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 try (data as? UIImage)?.jpegData(compressionQuality: 1)?.write(to: URL(fileURLWithPath: filePath))
             } else if data is Data {
                 try (data as? Data)?.write(to: URL(fileURLWithPath: filePath))
+            } else if data is String {
+                try (data as? String)?.write(to: URL(fileURLWithPath: filePath), atomically: true, encoding: .utf8)
+            } else {
+                return
             }
             
             let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: contentType, livePhoto: false)

+ 1 - 1
iOSClient/Utility/CCUtility.m

@@ -152,7 +152,7 @@
     number++;
     if (number >= 9999) number = 1;
     
-    [UICKeyChainStore setString:[NSString stringWithFormat:@"%ld", number] forKey:@"incrementalnumber"];
+    [UICKeyChainStore setString:[NSString stringWithFormat:@"%ld", number] forKey:@"incrementalnumber" service:k_serviceShareKeyChain];
     
     return [NSString stringWithFormat:@"%04ld", number];
 }