hufans / react-native-alioss

aliyun oss for react native
MIT License
16 stars 8 forks source link

expo环境下报错:TypeError: Cannot read property 'initWithSecurityToken' of null #16

Open Qyokizzzz opened 11 months ago

Qyokizzzz commented 11 months ago

我的代码:

const configuration = { maxRetryCount: 3, timeoutIntervalForRequest: 30, timeoutIntervalForResource: 24 60 60, };

export async function upload(bucketpath: string, uri: string) { const filename = uri.split('/').pop(); const res = await getOssOpts(); const ossOpts = res.data.queryResult; const { AccessKeyId, AccessKeySecret, SecurityToken } = ossOpts; AliyunOSS.initWithSecurityToken( SecurityToken, AccessKeyId, AccessKeySecret, 'oss-cn-beijing', configuration, ); const response = await AliyunOSS.asyncUpload( appConfig.bucketName as string, ${bucketpath}/${filename}, uri, ); } 环境: win10 "react": "18.2.0", "react-native": "0.72.6", "rn-alioss": "^0.2.5", "expo": "^49.0.21", 错误信息: WARN Possible Unhandled Promise Rejection (id: 0): TypeError: Cannot read property 'initWithSecurityToken' of null TypeError: Cannot read property 'initWithSecurityToken' of null at initWithSecurityToken (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:187949:35) at ?anon0 (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:187837:82) at next (native) at asyncGeneratorStep (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:28413:26) at _next (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:28432:29) at tryCallOne (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/3n472i6k/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/Users/kudo/01_Work/Repos/expo/expo/android/versioned-react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/MinSizeRel/3n472i6k/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native) at anonymous (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:35046:26) at _callTimer (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:34925:17) at _callReactNativeMicrotasksPass (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:34970:17) at callReactNativeMicrotasks (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:35176:44) at callReactNativeMicrotasks (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:6077:46) at anonymous (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:5851:45) at guard (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:6050:15) at flushedQueue (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:5850:21) at callFunctionReturnFlushedQueue (http://192.168.101.27:8081/index.bundle//&platform=android&dev=true&hot=false&lazy=true:5835:33)