Marino Faggiana 6 年之前
父节点
当前提交
03fdbd2234
共有 1 个文件被更改,包括 24 次插入8 次删除
  1. 24 8
      PickerFileProvider/FileProvider.swift

+ 24 - 8
PickerFileProvider/FileProvider.swift

@@ -1053,6 +1053,30 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
         completionHandler(item, nil)
     }
     
+    // --------------------------------------------------------------------------------------------
+    //  MARK: - Upload delegate
+    // --------------------------------------------------------------------------------------------
+    
+    func uploadFileSuccessFailure(_ fileName: String!, fileID: String!, assetLocalIdentifier: String!, serverUrl: String!, selector: String!, selectorPost: String!, errorMessage: String!, errorCode: Int) {
+        
+        if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account = %@ AND fileID = %@", account, fileID)) {
+            
+            NCManageDatabase.sharedInstance.setLocalFile(fileID: fileID, date: nil, exifDate: nil, exifLatitude: nil, exifLongitude: nil, fileName: nil, etag: metadata.etag, etagFPE: metadata.etag)
+            
+            // rename Directory : <base storage directory>/prevFileID/<item file name> to <base storage directory>/fileID/<item file name>
+            do {
+                let atPath = fileProviderStorageURL!.path + "/" + assetLocalIdentifier.replacingOccurrences(of: k_assetLocalIdentifierFileProviderStorage, with: "")
+                let toPath = fileProviderStorageURL!.path + "/" + fileID
+                try FileManager.default.moveItem(atPath: atPath, toPath: toPath)
+            } catch let error as NSError {
+                NSLog("Unable to create directory \(error.debugDescription)")
+            }
+            
+            let item = FileProviderItem(metadata: metadata, serverUrl: serverUrl)
+            self.refreshEnumerator(identifier: item.itemIdentifier, serverUrl: serverUrl)
+        }
+    }
+    
     // --------------------------------------------------------------------------------------------
     //  MARK: - User Function
     // --------------------------------------------------------------------------------------------
@@ -1165,14 +1189,6 @@ class FileProvider: NSFileProviderExtension, CCNetworkingDelegate {
         
         return resultFileName
     }
-    
-    // --------------------------------------------------------------------------------------------
-    //  MARK: - Upload delegate
-    // --------------------------------------------------------------------------------------------
-    
-    func uploadFileSuccessFailure(_ fileName: String!, fileID: String!, assetLocalIdentifier: String!, serverUrl: String!, selector: String!, selectorPost: String!, errorMessage: String!, errorCode: Int) {
-        print("x")
-    }
 }
 
 // --------------------------------------------------------------------------------------------