Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(RCTBlobManager): Prevent RCTConvert error for allowed null blob t…
…ypes (facebook#32397) Summary: While reworking our media picker, I ended up replacing the RNFetchBlob library to use `fetch()`, leveraging React Native's file resolver (especially to interpret `photos://` URI paths). The migration process was pretty straightforward, however I kept getting RCTConvert errors when calling `fetch` with a `PUT` method and a blob body: ``` JSON value '<null>' of type NSNull cannot be converted to NSString +[RCTConvert NSString:] RCTConvert.m:59 -[RCTBlobManager handleNetworkingRequest:] -[RCTNetworking processDataForHTTPQuery:callback:] -[RCTNetworking buildRequest:completionBlock:] -[RCTNetworking sendRequest:callback:] __invoking___ -[NSInvocation invoke] -[NSInvocation invokeWithTarget:] -[RCTModuleMethod invokeWithBridge:module:arguments:] Test Plan: I'll put my `fetch` snippet here. This is using a third-party library in order to get a signed URL, but it is otherwise pretty straightforward. This snippet would trigger an error before the changes introduced by this PR. ```js // Setup (specific to third-party lib) const key = `file/path/in/bucket` const params = { Key: key, Bucket: 'my.awesome.bucket', } const s3url = await s3.getSignedUrl('putObject', params) // Letting RN handle how to retrieve a platform-specific resource URI const localFetch = await fetch(localPath) // Getting the blob to upload as octet-stream const blob = await localFetch.blob() // Actually uploading await fetch(s3url, { method: 'PUT', headers: { 'Accept': 'application/json', 'Content-Type': 'application/octet-stream', }, body: blob, }) ``` Reviewed By: RSNara Differential Revision: D31625636 Pulled By: sota000 fbshipit-source-id: a7770018bc3ff2f41321b1bd26ec145b86b18784
- Loading branch information