Эх сурвалжийг харах

add parameterproviderIdentifier

Marino Faggiana 8 жил өмнө
parent
commit
5c6e9fa0a1

+ 12 - 3
Picker/DocumentPickerViewController.swift

@@ -32,14 +32,15 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     lazy var fileCoordinator: NSFileCoordinator = {
     
         let fileCoordinator = NSFileCoordinator()
-        fileCoordinator.purposeIdentifier = self.providerIdentifier
+        fileCoordinator.purposeIdentifier = self.parameterProviderIdentifier
         return fileCoordinator
         
     }()
     
     var parameterMode : UIDocumentPickerMode?
     var parameterOriginalURL: URL?
-
+    var parameterProviderIdentifier: String!
+    
     var metadata : CCMetadata?
     var recordsTableMetadata : [TableMetadata]?
     var titleFolder : String?
@@ -136,6 +137,7 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     
     override func prepareForPresentation(in mode: UIDocumentPickerMode) {
         
+        // ------------------> Settings parameter ----------------
         if parameterMode == nil {
             parameterMode = mode
         }
@@ -144,6 +146,11 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
             parameterOriginalURL = originalURL
         }
         
+        if parameterProviderIdentifier == nil {
+            parameterProviderIdentifier = providerIdentifier
+        }
+        // -------------------------------------------------------
+        
         switch mode {
             
         case .exportToService:
@@ -355,8 +362,9 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     func uploadFileSuccess(_ fileID: String!, serverUrl: String!, selector: String!, selectorPost: String!) {
         
         hud.hideHud()
+        let url = URL(string: "file://\(directoryUser!)/\(fileID!)".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)
         
-        dismissGrantingAccess(to: parameterOriginalURL)
+        dismissGrantingAccess(to: nil)
     }
     
     //  MARK: - Download Thumbnail
@@ -574,6 +582,7 @@ extension DocumentPickerViewController: UITableViewDataSource {
         
             nextViewController.parameterMode = parameterMode
             nextViewController.parameterOriginalURL = parameterOriginalURL
+            nextViewController.parameterProviderIdentifier = parameterProviderIdentifier
             nextViewController.localServerUrl = CCUtility.stringAppendServerUrl(localServerUrl!, addServerUrl: dir)
             nextViewController.titleFolder = recordTableMetadata?.fileNamePrint
         

+ 3 - 1
iOSClient/Networking/CCNetworking.m

@@ -1178,8 +1178,10 @@
         } else {
             
             // -- Go to upload --
-            [CCGraphics createNewImageFrom:metadata.fileNamePrint directoryUser:_directoryUser fileNameTo:metadata.fileID fileNamePrint:metadata.fileNamePrint size:@"m" imageForUpload:YES typeFile:metadata.typeFile writePreview:YES optimizedFileName:NO];
             
+#ifndef EXTENSION
+            [CCGraphics createNewImageFrom:metadata.fileNamePrint directoryUser:_directoryUser fileNameTo:metadata.fileID fileNamePrint:metadata.fileNamePrint size:@"m" imageForUpload:YES typeFile:metadata.typeFile writePreview:YES optimizedFileName:NO];
+#endif
             [CCCoreData addMetadata:metadata activeAccount:_activeAccount activeUrl:_activeUrl typeCloud:_typeCloud context:_context];
             
             [self uploadURLSession:fileName fileNamePrint:fileName serverUrl:serverUrl directoryID:metadata.directoryID sessionID:uploadID session:metadata.session taskStatus:taskStatus assetDate:assetDate assetMediaType:assetMediaType cryptated:cryptated onlyPlist:onlyPlist parentRev:parentRev selector:selector];

+ 1 - 0
iOSClient/Utility/CCUtility.h

@@ -142,6 +142,7 @@
 
 + (void)moveFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
 + (void)copyFileAtPath:(NSString *)atPath toPath:(NSString *)toPath;
++ (void)createSymbolicLinkAtURL:(NSURL *)atURL destinationURL:( NSURL *)destinationURL;
 + (void)removeAllFileID_UPLOAD_ActiveUser:(NSString *)activeUser activeUrl:(NSString *)activeUrl;
 
 + (NSString *)deletingLastPathComponentFromServerUrl:(NSString *)serverUrl;

+ 6 - 0
iOSClient/Utility/CCUtility.m

@@ -609,6 +609,12 @@
     }
 }
 
++ (void)createSymbolicLinkAtURL:(NSURL *)atURL destinationURL:( NSURL *)destinationURL
+{
+    [[NSFileManager defaultManager] removeItemAtURL:destinationURL error:nil];
+    [[NSFileManager defaultManager] createSymbolicLinkAtURL:atURL withDestinationURL:destinationURL error:nil];
+}
+
 + (void)removeAllFileID_UPLOAD_ActiveUser:(NSString *)activeUser activeUrl:(NSString *)activeUrl
 {
     NSString *file;