aliyun / aliyun-oss-android-sdk

Android SDK for aliyun object storage service
806 stars 306 forks source link

2.9.11 版上传时无法正确的处理 http 升级 https 的响应结果 #336

Closed DevDengChao closed 2 years ago

DevDengChao commented 2 years ago

复现步骤:

  1. 新建 example-bucket 存储桶
  2. 为 example-bucket 配置 CDN 域名 cdn.example.com
  3. 设置 cdn.example.com CDN 的强制跳转为 http -> https.
  4. 使用 JAVA OSS SDK 3.14.0 模拟客户端拿到 accessKeyId, accessKeySecret, stsToken 等信息后进行简单上传的行为,确认可以直接使用 cdn.example.com 域名 (不用补全 http:// 或 https:// 协议前缀) 作为 endpoint 进行上传。
  5. 使用 Android OSS SDK 2.9.11 进行客户端集成,使用与 JAVA SDK 同样的配置流程后进行上传, 结果触发异常。

image

Ref:

DevDengChao commented 2 years ago

现在可行的解决方案:

  OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(accessKeyId, accessKeySecret, securityToken);
  ClientConfiguration conf = new ClientConfiguration();
  if (!endpoint.startsWith("http")) {
      endpoint = "https://" + endpoint;  // 手动拼接 https:// 协议前缀
  }
  OSSClient mOss = new OSSClient(context, endpoint, credentialProvider, conf);
DevDengChao commented 2 years ago

fixed in https://github.com/aliyun/aliyun-oss-android-sdk/commit/55d4fa3e955838bda6c589a88385c0a58c5dd0ed