I am getting the same issue. When passing a Blob
as suggested into sendFileMessage
, I get the following error:
[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'a.data.name')]
- node_modules/sendbird/SendBird.min.js:6:14434 in value
- node_modules/sendbird/SendBird.min.js:6:18726 in checkRouting$argument_0
- node_modules/sendbird/SendBird.min.js:6:14977 in value
- node_modules/sendbird/SendBird.min.js:6:18566 in value
- node_modules/sendbird/SendBird.min.js:6:58591 in r.upload.progressHandler
- node_modules/sendbird/SendBird.min.js:6:80935 in value
- node_modules/sendbird/SendBird.min.js:6:57933 in value
- node_modules/sendbird/SendBird.min.js:6:176974 in value
- node_modules/sendbird/SendBird.min.js:6:175342 in messageQueue.map$argument_0
- node_modules/sendbird/SendBird.min.js:6:175836 in value
- node_modules/sendbird/SendBird.min.js:6:174357 in value
- node_modules/sendbird/SendBird.min.js:6:178997 in value
- node_modules/sendbird/SendBird.min.js:6:127683 in value
* src/sections/inbox/screens/ChatScreen/index.tsx:137:6 in useCallback$argument_0
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:293:29 in invoke
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:154:27 in invoke
- node_modules/regenerator-runtime/runtime.js:164:18 in PromiseImpl.resolve.then$argument_0
- node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
When adding a name field to the blob object to attempt to fix this, I get the same vague “Request failed” error mentioned in Riyan’s post.
Here’s my code for reference:
const { uri } = imagePickerResult;
// Example URI: file:/data/user/0/host.exp.exponent/cache/ExperienceData/PROJ/ImagePicker/85e7df66-4716-4bdb-bd38-867b764f75b1.jpg
const response = await fetch(uri);
const blob = await response.blob();
const params = new SB_INSTANCE.FileMessageParams();
// sendFileMessage expects a `File` despite the docs saying it expects a `Blob`
params.file = blob as File;
params.fileName = 'Test file';
params.fileSize = blob.size;
params.mimeType = blob.type;
params.customType = '';
params.data = '';
channel.sendFileMessage(params, cb);
Relevant dependencies:
"expo": "~40.0.0",
"expo-image-picker": "~9.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"sendbird": "^3.0.144"