mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 12:15:37 +08:00
[ReactNative] Allow uploading native files (e.g. photos) and FormData via XMLHttpRequest
This commit is contained in:
@@ -282,6 +282,24 @@ BOOL RCTImageHasAlpha(CGImageRef image)
|
||||
}
|
||||
}
|
||||
|
||||
NSError *RCTErrorWithMessage(NSString *message)
|
||||
{
|
||||
NSDictionary *errorInfo = @{NSLocalizedDescriptionKey: message};
|
||||
NSError *error = [[NSError alloc] initWithDomain:RCTErrorDomain code:0 userInfo:errorInfo];
|
||||
return error;
|
||||
}
|
||||
|
||||
void RCTDispatchCallbackOnMainQueue(RCTResultOrErrorBlock callback, NSError *error, id result)
|
||||
{
|
||||
if ([NSThread isMainThread]) {
|
||||
callback(error, result);
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
callback(error, result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
id RCTNullIfNil(id value)
|
||||
{
|
||||
return value ?: (id)kCFNull;
|
||||
|
||||
Reference in New Issue
Block a user