Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android虚拟机 上传失败 Can't get a federation token #10

Closed
cys85 opened this issue Jul 17, 2018 · 10 comments
Closed

Android虚拟机 上传失败 Can't get a federation token #10

cys85 opened this issue Jul 17, 2018 · 10 comments

Comments

@cys85
Copy link

cys85 commented Jul 17, 2018

环境是: android 虚拟机;

"aliyun-oss-react-native": "^1.0.0-alpha.5",
"react-native": "0.55.4",
"react-native-image-picker": "^0.26.10",

采用 initWithPlainTextAccessKey 方式 初始化的 AliyunOSS 调用 asyncUpload API上传, 在IOS下一切正常, android 下 出现异常,异常信息 [Info] 07-17 14:25:19.988 4873 5287 I ReactNativeJS: { [Error: Can't get a federation token 07-17 14:25:19.988 4873 5287 I ReactNativeJS: [ErrorMessage]: Can't get a federation token] framesToPop: 1, code: 'EUNSPECIFIED' }

我增加了

AliyunOSS.addEventListener('uploadProgress', (p) => {
      console.log('here?');
    });

好像这个方法都没有进来

参数格式如下

[Info] 07-17 15:31:38.498  4231  5445 I ReactNativeJS: 'bucketName', 'mxb-bucket'
07-17 15:31:38.499  4231  5445 I ReactNativeJS: 'objectKey', '9b00b88bb0e565ef153181269835840383image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'
07-17 15:31:38.499  4231  5445 I ReactNativeJS: 'url', 'file:///storage/emulated/0/Android/data/com.app_merchant_tao_mian_xi/files/Pictures/image-0459516f-6e3d-4891-84c9-387c4e89a350.jpg'
@cys85 cys85 changed the title Android 下 上传失败 Android虚拟机 上传失败 Can't get a federation token Jul 17, 2018
@cys85
Copy link
Author

cys85 commented Jul 17, 2018

我在真机上进行了测试, 同样的问题。

@luozhang002
Copy link
Collaborator

luozhang002 commented Jul 17, 2018

@cys85 其实这个底层接口调用的也是安卓iOSSDK底层的,实际上这个直接传明文的AK SK的接口已经置为废弃,建议使用STS。后期JS 端也会慢慢把这个接口废弃的.事实上android端这边的代码我的逻辑还是有点问题,因为当时考虑到直接传入AK SK的方式不支持我就没动, 我这边也可以改一发的,以后我的文档上会建议不使用这个授权api,移动端应用来说明文不安全

@cys85
Copy link
Author

cys85 commented Jul 17, 2018

@luozhang002 是的, 我这边看到了, 我已经改为了 STS, 实测 好用, 已经通过了, 非常感谢。

@luozhang002
Copy link
Collaborator

@cys85 因为处于alpha阶段,目前官网还没正式挂,后期修复用户反馈的问题后,会慢慢的发正式版本,同时文档也会同步到阿里云官网

@luozhang002
Copy link
Collaborator

luozhang002 commented Jul 17, 2018

@cys85 虽然我们不建议使用initWithPlainTextAccessKey接口授权,但是你本地测试也是OK的, 你提的这个问题也已经修复,版本1.0.0-alpha.6,有问题也欢迎加入项目开发

@cys85
Copy link
Author

cys85 commented Jul 17, 2018

@luozhang002 非常感谢

@cys85
Copy link
Author

cys85 commented Jul 21, 2018

@luozhang002
AliyunOSS.initWithSecurityToken(signature, accessKey, endPoint, configuration);
这里面的参数 ‘signature’ 是个对象还是字符串呢,里面是不是包含了 securityToken、accessKeyId、accessKeySecret、expiration

@cys85
Copy link
Author

cys85 commented Jul 21, 2018

@luozhang002
我看了源码, 发现 initWithSecurityToken 参数 与文档中所描述的不一致, 正确的参数如下:
AliyunOSS.initWithSecurityToken(securityToken, accessKeyId, accessKeySecret, endPoint, configuration);

@luozhang002
Copy link
Collaborator

luozhang002 commented Jul 21, 2018

@cys85 正确的是这种AliyunOSS.initWithSecurityToken(securityToken, accessKeyId, accessKeySecret, endPoint, configuration); 文档我这边需要修改下的。感谢反馈

@luozhang002
Copy link
Collaborator

@cys85 文档已更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants