Open nschild opened 2 years ago
@nschild
Can you please provide more context on what you're trying to do? Is this issue with React Native, or the Cloudinary IOS SDK?
@patrick-tolosa Thanks for the response, Although I did upgrade react native, I dont know what would be the cause of the error as the data that is sent to the cloudinary sdk looks the same. I did update ios recently as well and since the cloudinary sdk is throwing the error, I thought I would start here.
Below is the sdk implementation, all we are doing is uplaoding a file, pretty simple.
// RNTCloudinaryManager.m
#import "RNTCloudinaryManager.h"
#import <React/RCTBridgeModule.h>
#import <React/RCTConvert.h>
#import <Cloudinary-Swift.h>
@implementation RNTCloudinaryManager
RCT_EXPORT_MODULE(CloudinaryModule);
RCT_EXPORT_METHOD(uploadFile:(NSString *)filePath
fileData:(NSDictionary *)fileData
uploadFileWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
if (!_cloudinary) {
NSString *cloudinaryCloudName = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"CLOUDINARY_CLOUD_NAME"];
CLDConfiguration *config;
config = [[CLDConfiguration alloc] initWithCloudName:cloudinaryCloudName apiKey:nil apiSecret:nil privateCdn:false secure:false cdnSubdomain:false secureCdnSubdomain:false secureDistribution:nil cname:nil uploadPrefix:nil];
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
sessionConfig.timeoutIntervalForRequest = 1800; // 30mins to prevent timeouts for large uploads
sessionConfig.timeoutIntervalForResource = 1800; // 30mins to prevent timeouts for large uploads
_cloudinary = [[CLDCloudinary alloc] initWithConfiguration:config networkAdapter:nil sessionConfiguration:sessionConfig];
}
NSURL *fileUrl = [RCTConvert NSURL:filePath];
NSString *resourceType = [fileData objectForKey:@"resourceType"];
NSString *context = [fileData objectForKey:@"context"];
NSString *uploadPreset = [NSString stringWithFormat:@"%@%@", @"default-", resourceType];
CLDUploader *uploader = [_cloudinary createUploader];
CLDUploadRequestParams *params = [[CLDUploadRequestParams alloc] init];
[ params setResourceTypeFromString:resourceType ];
[ params setContext:context ];
[ uploader
uploadLargeWithUrl:fileUrl
uploadPreset:uploadPreset
params:params
chunkSize:20 * 1024 * 1024
progress:^void(NSProgress *progressResult) {
// TODO: Can pass percentComplete value to RN in the future if we want to display a progress bar in the UI
// double percentComplete = [progressResult fractionCompleted];
// NSLog(@"Cloudinary uploader: progress percent completed %f", percentComplete);
if ([progressResult isFinished]) {
NSLog(@"Cloudinary uploader progress: finished");
NSDictionary *dictRes = @{ @"ok":@YES };
resolve(dictRes);
}
}
completionHandler:^(CLDUploadResult *uploadResult, NSError *errorResult) {
if (uploadResult) {
// not in use by app - see progress handler above
// cloudinary API was very long time to return 200 response, or would time-out, due to time required for video rotation fix
}
if (errorResult) {
NSLog(@"Cloudinary uploader error: %@", [errorResult localizedDescription]);
reject([NSString stringWithFormat:@"%li", (long)[errorResult code]], [errorResult localizedDescription], errorResult);
}
}
];
}
@end
Bug report for Cloudinary iOS SDK
Before proceeding, please update to latest version and test if the issue persists
Describe the bug in a sentence or two.
Trying to upload file. Upgraded to react native 0.64.x and not working now. Do you know what this error means?
Issue Type (Can be multiple)
[ ] Build - Can’t install or import the SDK [ ] Performance - Performance issues [ x] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)
Steps to reproduce
idik
Error screenshots or Stack Trace (if applicable)
Build/Dependency management
[x ] Cocoa-Pods [ ] Carthage [ ] Manual import [ ] Other (Specify)
Is the issue reproducible only on a specific device?
[x ] No [ ] Yes (specify model + iOS version)
Versions and Libraries (fill in the version numbers)
iOS Cloudinary SDK version - 3.1.0 OSX (on the dev environment) - 11.6 XCode - 13.2.1 Swift - 5 Target iOS - 12.1
Repository If possible, please provide a link to a reproducible repository that showcases the problem