Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

fix extensions

rorycleare69933dae795
diff --git a/clearcam/SceneDelegate.m b/clearcam/SceneDelegate.m
index 86ad6ec..8f96503 100644
--- a/clearcam/SceneDelegate.m
+++ b/clearcam/SceneDelegate.m
@@ -187,10 +187,14 @@
}
NSLog(@"Decrypted data successfully. Size: %lu bytes", (unsigned long)decryptedData.length);
- // Save the decrypted data as a .jpg file
- NSString *fileName = [[aesFileURL lastPathComponent] stringByDeletingPathExtension]; // Remove .aes extension
- NSString *jpgFileName = [fileName stringByAppendingPathExtension:@"jpg"];
- NSURL *jpgFileURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0] URLByAppendingPathComponent:jpgFileName];
+ // Remove only the .aes extension
+ NSString *fileName = [aesFileURL lastPathComponent];
+ if ([fileName hasSuffix:@".aes"]) {
+ fileName = [fileName stringByReplacingOccurrencesOfString:@".aes" withString:@"" options:NSBackwardsSearch range:NSMakeRange(0, fileName.length)];
+ }
+ //todo, can be any file type
+ NSURL *jpgFileURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0] URLByAppendingPathComponent:fileName];
+
NSError *writeError = nil; // Temporary error variable for writing
[decryptedData writeToURL:jpgFileURL options:NSDataWritingAtomic error:&writeError];
diff --git a/clearcam/SceneState.m b/clearcam/SceneState.m
index ce3dc3e..f409bff 100644
--- a/clearcam/SceneState.m
+++ b/clearcam/SceneState.m
@@ -201,7 +201,8 @@
[bodyData appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//todo change jpg to aes?
- [bodyData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@\"\r\n", encryptImage ? [[[filePathToSend lastPathComponent] stringByDeletingPathExtension] stringByAppendingString:@".aes"] : [filePathToSend lastPathComponent]] dataUsingEncoding:NSUTF8StringEncoding]];
+ [bodyData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@\"\r\n", encryptImage ? [[filePathToSend lastPathComponent] stringByAppendingString:@".aes"] : [filePathToSend lastPathComponent]
+] dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:[[NSString stringWithFormat:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[bodyData appendData:fileData];
[bodyData appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];