Add object detection, tracking, mobile notifications, and search to any security camera.
send upload size
roryclear3203f30ec1c6
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 81c7ec3..5e9968b 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -973,7 +973,7 @@CGSize renderSize = naturalSize;if (low_res) {- CGFloat scale = MIN(960.0 / naturalSize.width, 540.0 / naturalSize.height);+ CGFloat scale = MIN(1280.0 / naturalSize.width, 720.0 / naturalSize.height);transform = CGAffineTransformScale(transform, scale, scale);renderSize = CGSizeApplyAffineTransform(naturalSize, CGAffineTransformMakeScale(scale, scale));}@@ -997,7 +997,7 @@if (low_res) {exportSession.videoComposition = videoComposition;exportSession.shouldOptimizeForNetworkUse = YES;- exportSession.fileLengthLimit = 5 * 1024 * 1024 * (trimmedDuration / 60.0); // ~5 MB per minute+ exportSession.fileLengthLimit = 20 * 1024 * 1024 * (trimmedDuration / 60.0);} else if (orientation == 1 || orientation == 4) {exportSession.videoComposition = videoComposition;}diff --git a/clearcam/Notification.m b/clearcam/Notification.mindex 360ae6c..d661c6f 100644--- a/clearcam/Notification.m+++ b/clearcam/Notification.m@@ -81,11 +81,15 @@return;}+ // Calculate file size (in bytes)+ NSUInteger fileSize = [imageData length];+// 🔹 STEP 1: Request a Presigned R2 URL from the ServerNSURLComponents *components = [NSURLComponents componentsWithString:[server stringByAppendingString:@"/upload"]];NSURLQueryItem *fileItem = [NSURLQueryItem queryItemWithName:@"filename" value:fileName];NSURLQueryItem *sessionItem = [NSURLQueryItem queryItemWithName:@"session_token" value:sessionToken];- components.queryItems = @[fileItem, sessionItem]; // Include session_token here+ NSURLQueryItem *sizeItem = [NSURLQueryItem queryItemWithName:@"size" value:[NSString stringWithFormat:@"%lu", (unsigned long)fileSize]];+ components.queryItems = @[fileItem, sessionItem, sizeItem]; // Include filename, session_token, and sizeNSURL *uploadRequestURL = components.URL;NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:uploadRequestURL];@@ -110,6 +114,7 @@NSMutableURLRequest *r2Request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:presignedR2URL]];[r2Request setHTTPMethod:@"PUT"];[r2Request setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];+ [r2Request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)fileSize] forHTTPHeaderField:@"Content-Length"]; // Add Content-Length headerNSURLSessionUploadTask *r2UploadTask = [[NSURLSession sharedSession] uploadTaskWithRequest:r2Request fromData:imageData completionHandler:^(NSData *r2Data, NSURLResponse *r2Response, NSError *r2Error) {if (r2Error) {@@ -124,13 +129,11 @@}}];- [r2UploadTask resume]; // Start the R2 upload+ [r2UploadTask resume];}];- [uploadTask resume]; // Start the request to get the presigned URL+ [uploadTask resume];}---@end+