marinofaggiana 5 years ago
parent
commit
1c19889c35
3 changed files with 47 additions and 0 deletions
  1. 24 0
      iOSClient/Main/CCMain.m
  2. 3 0
      iOSClient/Utility/CCUtility.h
  3. 20 0
      iOSClient/Utility/CCUtility.m

+ 24 - 0
iOSClient/Main/CCMain.m

@@ -1129,6 +1129,30 @@
             // Add Medtadata for upload
             (void)[[NCManageDatabase sharedInstance] addMetadata:metadataForUpload];
             
+            // Add Medtadata for upload
+            if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive && CCUtility.getMOVLivePhoto) {
+                
+                NSUInteger index = [assets indexOfObject:asset];
+                NSURL *url = [urls objectAtIndex:index];
+                tableMetadata *metadataMOVForUpload = [tableMetadata new];
+                NSString *fileName = [NSString stringWithFormat:@"%@.mov", fileNameWithoutExtension];
+                unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:url.path error:nil] fileSize];
+
+                metadataMOVForUpload.account = appDelegate.activeAccount;
+                metadataMOVForUpload.date = [NSDate new];
+                metadataMOVForUpload.ocId = [CCUtility createMetadataIDFromAccount:appDelegate.activeAccount serverUrl:serverUrl fileNameView:fileName directory:false];
+                metadataMOVForUpload.fileName = fileName;
+                metadataMOVForUpload.fileNameView = fileName;
+                metadataMOVForUpload.serverUrl = serverUrl;
+                metadataMOVForUpload.session = session;
+                metadataMOVForUpload.sessionSelector = selectorUploadFile;
+                metadataMOVForUpload.size = fileSize;
+                metadataMOVForUpload.status = k_metadataStatusWaitUpload;
+                metadataMOVForUpload.url = url.path;
+                
+                (void)[[NCManageDatabase sharedInstance] addMetadata:metadataMOVForUpload];
+            }
+                        
             [appDelegate startLoadAutoDownloadUpload];
         }
     }

+ 3 - 0
iOSClient/Utility/CCUtility.h

@@ -174,6 +174,9 @@
 + (BOOL)getDarkModeDetect;
 + (void)setDarkModeDetect:(BOOL)disable;
 
++ (BOOL)getMOVLivePhoto;
++ (void)setMOVLivePhoto:(BOOL)set;
+
 // ===== Varius =====
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 20 - 0
iOSClient/Utility/CCUtility.m

@@ -687,6 +687,26 @@
     [UICKeyChainStore setString:sDisable forKey:@"darkModeDetect" service:k_serviceShareKeyChain];
 }
 
++ (BOOL)getMOVLivePhoto
+{
+    NSString *valueString = [UICKeyChainStore stringForKey:@"movLivePhoto" service:k_serviceShareKeyChain];
+    
+    // Default TRUE
+    if (valueString == nil) {
+        [self setFormatCompatibility:YES];
+        return true;
+    }
+    
+    return [valueString boolValue];
+}
+
++ (void)setMOVLivePhoto:(BOOL)set
+{
+    NSString *sSet = (set) ? @"true" : @"false";
+    [UICKeyChainStore setString:sSet forKey:@"movLivePhoto" service:k_serviceShareKeyChain];
+}
+
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Various =====
 #pragma --------------------------------------------------------------------------------------------