aliyun / aliyun-oss-react-native

MIT License
148 stars 100 forks source link

Upload file failed with error: "framesToPop":1,"code":"EUNSPECIFIED" #8

Closed ghost closed 6 years ago

ghost commented 6 years ago
configuration:
const AliOSS = {
    endpoint: 'oss-cn-hongkong.aliyuncs.com',
    config: {
        maxRetryCount: 3,
        timeoutIntervalForRequest: 30,
        timeoutIntervalForResource: 24 * 60 * 60
    },
    securityToken: '', // get from server
    accessKey: '',
    secretKey: '',
};

...

AliyunOSS.enableDevMode();
AliyunOSS.initWithSecurityToken(r.securityToken, r.accessKeyId, r.accessKeySecret, AliOSS.endpoint, AliOSS.config)
AliyunOSS.addEventListener('uploadProgress', (p) => {
    let per = parseInt(p.currentSize / p.totalSize * 10);
    if (per !== logCount) {
        logCount = per;
        JLLog('uploadProgress ' + per);
    }
});
use like this :
AliyunOSS.asyncUpload('bwoil-file', 'jonglim/hand-test' + rendom++, source[0].uri).then((res) => {
    JLLog({ AliyunOSS: res })
}).catch((error) => {
    JLLog({ AliyunOSS: error })
})
log
07-13 17:18:14.924  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 1
07-13 17:18:14.932  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 2
...
07-13 17:18:14.966  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 9
07-13 17:18:14.970  7028 12904 I ReactNativeJS: >> NewPostScreen.js << uploadProgress 10
07-13 17:18:15.019  7028 12904 I ReactNativeJS: >> NewPostScreen.js << {"AliyunOSS":{"framesToPop":1,"code":"EUNSPECIFIED"}}

Anyone know what's wrong with this?

luozhang002 commented 6 years ago

@LinZh107 1. 请确认采取的是1.0.0-alpha.5的版本。(2)android端吗?(3)你代码里这个东西 'jonglim/hand-test' + rendom++ 是什么格式

ghost commented 6 years ago

@luozhang002 你好,

  1. 是1.0.0-alpha.5的版本,android端,ios还没试
  2. 第二个参数 ['jonglim/hand-test' + rendom++] 最终会是拼接成jonglim/hand-test9527 之类的字符串
  3. 初始化 initWithSecurityToken 的其他参数都是后台返回的,asyncUpload 的第三个参数是手机本地文件路径,

依照打印log来看是不是说有上传了? (感觉上传一张手机screenshot还是要了好几秒的~)

luozhang002 commented 6 years ago

uploadProgress看log你好像是有进度的,说明回调走了,应该是上传中,可以看你的bucket上看上有没有上传成功。你的那个手机本地路径是file:///开头的吗?环境操作的时候是模拟器还是真机

luozhang002 commented 6 years ago

你读取本地文件的时候用的是react native的那个库,这个报错我react -native一下framesToPop":1,"code":"EUNSPECIFIED @https://github.com/itinance/react-native-fs/issues/355 @https://github.com/idehub/react-native-billing/issues/47

GeekStyle commented 6 years ago

token 的权限和 所建目录的权限不匹配

ghost commented 6 years ago

@luozhang002 用真机跑的,文件路径是file:///开头, component 可以正常显示照片。

PS: 上传成功了。

原来是第二个参数'objectkey'没用对,这个参数实际是文件‘folder/filename’这样的结构,而且folder是后台管理的,只能多选一。可是关于用法,好像没看到有文档说明?

luozhang002 commented 6 years ago

@LinZh107 React Native这个项目后期会挂到官网,现在还处于收集反馈阶段,可能文档还不全面,我这变会不定期的更新的,感谢反馈