jlcool / aliossflutter

阿里云oss flutter
Apache License 2.0
76 stars 47 forks source link

上传图片报错:[ErrorMessage]: Compute signature failed!请问是哪的问题?Android #22

Open manburenshenglu opened 4 years ago

jlcool commented 4 years ago

签名错了吧,你用哪个方法签名的

manburenshenglu commented 4 years ago

12222222 我没有使用签名,麻烦问一下这个签名必须要签吗

manburenshenglu commented 4 years ago

alioss.init(Address.getOssSts(), "http://oss-cn-hangzhou.aliyuncs.com"); //监听初始化 alioss.responseFromInit.listen((data) { if (data) { print("初始化成功"); alioss.upload( "jaagro", file.path, fileKey, ); //监听上传 alioss.responseFromUpload.listen((data) { if (data.success) { setState(() { print("上传成功 key:" + data.key + " 服务器回调返回值:" + data.servercallback); }); } else { print("上传失败" + data.msg); } }); } else { print("初始化失败"); } });

jlcool commented 4 years ago

init方法第一个参数是sts验证的URL地址,使用keyid和Secret初始化可以使用secretInit方法

manburenshenglu commented 4 years ago

我是使用鉴权模式获取后台返回的token,好像不需要用到keyid和Secret吧

jlcool commented 4 years ago

你这个方法Address.getOssSts()返回的是什么

manburenshenglu commented 4 years ago

这个方法返回的是获取ststoken的接口地址,就只是一个接口而已,这样使用正确吗?

manburenshenglu commented 4 years ago

只是一个接口地址

jlcool commented 4 years ago

接口地址的话就没错,获取sts是在sdk中完成,你看你接口返回的是下面的格式吗

{
 "StatusCode": 200,
 "AccessKeyId":"STS.iA645eTOXEqP3cg3VeHf",
 "AccessKeySecret":"rV3VQrpFQ4BsyHSAvi5NVLpPIVffDJv4LojUBZCf",
 "Expiration":"2015-11-03T09:52:59Z", "SecurityToken":"CAES7QIIARKAAZPlqaN9ILiQZPS+JDkS/GSZN45RLx4YS/p3OgaUC+oJl3XSlbJ7StKpQ...."
}
manburenshenglu commented 4 years ago

66666666666666666666666666 后台返回的字段,要和你SDK中的完全一致吗需要?好像首字母大小写不一样。。。

manburenshenglu commented 4 years ago

这段代码是Android的原生Java代码,我贴上来的意思是为了说明后台返回的字段

jlcool commented 4 years ago

嗯,参数要一致

manburenshenglu commented 4 years ago

那这个有没有方法我转换为和你字段一致的方法,因为后台这个返回token的接口现在在生产环境用于好几个项目,不便修改接口返回的字段,谢谢

jlcool commented 4 years ago

那你fork后自己改一下代码吧

manburenshenglu commented 4 years ago

8888888 我fork了,但是你的项目好像没有支持AndroidX 在flutter1.12版本环境跑不起来

manburenshenglu commented 4 years ago

6789 楼主:我刚刚看错了。后台返回的字段和你SDK里取得是一样的

jlcool commented 4 years ago

返回数据要完全一致不能放到data里,上面的报错应该是项目中的compileSdkVersion改为28就可以了

zdjchengxu commented 4 years ago

8888888 我fork了,但是你的项目好像没有支持AndroidX 在flutter1.12版本环境跑不起来

我导入pub上的依赖也报这个错误,请问是如何解决的

ShengjieGeng commented 4 years ago

楼主您好,请问您的问题解决了吗,咱们的情况是一样的,我们后台返回的结构 image

初始化能成功,但是请求上传失败 image

image 求解,感激不尽

zdjchengxu commented 4 years ago

我后面自己写了一个上传,根据阿里云的文档,但我不知道适不适用于你 之前的报错一直是因为签名加密的问题,和要求的规则不匹配 后面我自己写的没有加密,直接明文传输,时间有点久,最近公司项目有点急,又在搞原生android,没时间弄flutter,如果你需要我先发个我写的给你参考参考

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用

发件人: android-melonmailto:notifications@github.com 发送时间: 2020年4月28日 17:40 收件人: jlcool/aliossfluttermailto:aliossflutter@noreply.github.com 抄送: zdjchengxumailto:zdjzdjzalion@outlook.com; Commentmailto:comment@noreply.github.com 主题: Re: [jlcool/aliossflutter] 上传图片报错:[ErrorMessage]: Compute signature failed!请问是哪的问题?Android (#22)

楼主您好,请问您的问题解决了吗,咱们的情况是一样的,我们后台返回的结构 [image]https://user-images.githubusercontent.com/18364968/80472294-18e51000-8977-11ea-990c-7b5488da0fdb.png

初始化能成功,但是请求上传失败 [image]https://user-images.githubusercontent.com/18364968/80472401-416d0a00-8977-11ea-9fa8-1908bf09f042.png

[image]https://user-images.githubusercontent.com/18364968/80472342-2ac6b300-8977-11ea-92fe-03611a890426.png 求解,感激不尽

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jlcool/aliossflutter/issues/22#issuecomment-620496181, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALN7EPSVXEV3SQX47TN5VBTRO2QBDANCNFSM4J64XNSA.

manburenshenglu commented 4 years ago

解决了吗?我是调用的原生代码实现oss上传图片了

ShengjieGeng commented 4 years ago

我后面自己写了一个上传,根据阿里云的文档,但我不知道适不适用于你 之前的报错一直是因为签名加密的问题,和要求的规则不匹配 后面我自己写的没有加密,直接明文传输,时间有点久,最近公司项目有点急,又在搞原生android,没时间弄flutter,如果你需要我先发个我写的给你参考参考 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用 发件人: android-melonmailto:notifications@github.com 发送时间: 2020年4月28日 17:40 收件人: jlcool/aliossfluttermailto:aliossflutter@noreply.github.com 抄送: zdjchengxumailto:zdjzdjzalion@outlook.com; Commentmailto:comment@noreply.github.com 主题: Re: [jlcool/aliossflutter] 上传图片报错:[ErrorMessage]: Compute signature failed!请问是哪的问题?Android (#22) 楼主您好,请问您的问题解决了吗,咱们的情况是一样的,我们后台返回的结构 [image]https://user-images.githubusercontent.com/18364968/80472294-18e51000-8977-11ea-990c-7b5488da0fdb.png 初始化能成功,但是请求上传失败 [image]https://user-images.githubusercontent.com/18364968/80472401-416d0a00-8977-11ea-9fa8-1908bf09f042.png [image]https://user-images.githubusercontent.com/18364968/80472342-2ac6b300-8977-11ea-92fe-03611a890426.png 求解,感激不尽 ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#22 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALN7EPSVXEV3SQX47TN5VBTRO2QBDANCNFSM4J64XNSA.

非常感谢 因为时间的问题,最后选择了另外一个sdkhttps://pub.dev/packages/aly_oss 因为之前我们Android,iOS已经接入了,所以后台给了一个请求token的接口,但是要适配这个sdk,需要后台根据要求的格式进行加密再返回数据