fix(oss): 软件版本下载 URL 优先走 download-endpoint
机 A 的 oss.aishufu.top:443 事件隔离期只放行管理 IP,软件版本直链落在该 入口时外部用户不可达。复用既有 download-endpoint(主机 B 反代回源), 上传预签名仍按 public-endpoint 签,避免签名 host 与反代 Host 不一致。
This commit is contained in:
+14
-2
@@ -181,7 +181,7 @@ public class OssStorageService {
|
||||
}
|
||||
String bucket = publicClientBucket();
|
||||
uploadFile(file, bucket, objectKey);
|
||||
return getPublicUrl(objectKey, bucket);
|
||||
return softwareVersionPublicUrl(objectKey);
|
||||
}
|
||||
|
||||
/** 公开 client 桶(软件版本包与教程包共用):默认 client,可用 aiimage.oss.software-version-bucket 覆盖。 */
|
||||
@@ -237,7 +237,19 @@ public class OssStorageService {
|
||||
if (objectKey == null || !objectKey.startsWith(SOFTWARE_VERSION_PREFIX)) {
|
||||
throw new IllegalArgumentException("software version objectKey must start with " + SOFTWARE_VERSION_PREFIX);
|
||||
}
|
||||
return getPublicUrl(objectKey, publicClientBucket());
|
||||
return softwareVersionPublicUrl(objectKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 软件版本包的公开下载 URL:优先 download-endpoint(主机 B 反代回源,公网可达),
|
||||
* 未配置时回退 public-endpoint。预签名 PUT 仍必须按 public-endpoint 签——签名与浏览器
|
||||
* 直连的 host 绑定,下载域名经反代会把 Host 改回 oss,拿下载域名签会验签失败。
|
||||
*/
|
||||
private String softwareVersionPublicUrl(String objectKey) {
|
||||
String base = downloadEndpoint();
|
||||
return base == null
|
||||
? getPublicUrl(objectKey, publicClientBucket())
|
||||
: buildPublicUrl(base, objectKey, publicClientBucket());
|
||||
}
|
||||
|
||||
/** 删除软件版本对象(client 桶);确认环节发现超限等异常时清理残留,避免公共桶悬挂大对象。 */
|
||||
|
||||
Reference in New Issue
Block a user