Browse Source

New createFolderSubFolderAutomaticUploadWithSubfolder on AppDelegate

Marino Faggiana 8 years ago
parent
commit
5d612d8c48
2 changed files with 37 additions and 1 deletions
  1. 1 1
      iOSClient/AppDelegate.h
  2. 36 0
      iOSClient/AppDelegate.m

+ 1 - 1
iOSClient/AppDelegate.h

@@ -169,7 +169,7 @@
 - (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector;
 
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector;
-
+- (BOOL)createFolderSubFolderAutomaticUploadWithSubfolder:(BOOL)useSubFolder assets:(NSArray *)assets;
 - (void)dropAutomaticUploadWithSelector:(NSString *)selector;
 
 @end

+ 36 - 0
iOSClient/AppDelegate.m

@@ -1415,6 +1415,42 @@
     });
 }
 
+- (BOOL)createFolderSubFolderAutomaticUploadWithSubfolder:(BOOL)useSubFolder assets:(NSArray *)assets
+{
+    NSString *folderPhotos = [CCCoreData getCameraUploadFolderNamePathActiveAccount:_activeAccount activeUrl:_activeUrl];
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:_activeUser withPassword:_activePassword withUrl:_activeUrl isCryptoCloudMode:NO];
+
+    if(![ocNetworking automaticCreateFolderSync:folderPhotos]) {
+        
+        // Activity & Message
+        NSString *description = NSLocalizedStringFromTable(@"_not_possible_create_folder_", @"Error", nil);
+        [app messageNotification:@"_error_" description:description visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+        [CCCoreData addActivityClient:@"" fileID:@"" action:k_activityDebugActionAutomaticUpload selector:@"" note:description type:k_activityTypeFailure verbose:k_activityVerboseDefault account:_activeAccount activeUrl:_activeUrl];
+        
+        return false;
+    }
+    
+    // Create if request the subfolders
+    if (useSubFolder) {
+        
+        for (NSString *dateSubFolder in [CCUtility createNameSubFolder:assets]) {
+            
+            if(![ocNetworking automaticCreateFolderSync:[NSString stringWithFormat:@"%@/%@", folderPhotos, dateSubFolder]]) {
+                
+                // Activity & Message
+                NSString *description = NSLocalizedString(@"_error_createsubfolders_upload_",nil);
+                [app messageNotification:@"_error_" description:description visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+                [CCCoreData addActivityClient:@"" fileID:@"" action:k_activityDebugActionAutomaticUpload selector:@"" note:description type:k_activityTypeFailure verbose:k_activityVerboseDefault account:_activeAccount activeUrl:_activeUrl];
+                
+                return false;
+            }
+        }
+    }
+
+    
+    return true;
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Open CCUploadFromOtherUpp  =====
 #pragma --------------------------------------------------------------------------------------------