Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cancelUpload not working #116

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ios/VydiaRNFileUploader.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
RCT_EXPORT_METHOD(cancelUpload: (NSString *)cancelUploadId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
[_urlSession getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
for (NSURLSessionTask *uploadTask in uploadTasks) {
if (uploadTask.taskDescription == cancelUploadId) {
if ([uploadTask.taskDescription isEqualToString:cancelUploadId]){
// == checks if references are equal, while isEqualToString checks the string value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this == comparison also an issue?

[data setObject:error.localizedDescription forKey:@"error"];
if (error.code == NSURLErrorCancelled) {
[self _sendEventWithName:@"RNFileUploader-cancelled" body:data];
} else {
[self _sendEventWithName:@"RNFileUploader-error" body:data];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like an issue to me, it is entering the if condition correctly.

[uploadTask cancel];
}
}
Expand Down