perf(OSS): 服务端对象读写与浏览器预签名拆成两张 client
Java 在自己机器上用 https://oss.aishufu.top 读写对象,等于走公网 EIP 回环 (ip route get 自己的公网 IP 是 via 192.168.0.253 dev eth0),实测只有 0.98 MB/s、 TLS 首字节 39ms;同一台走 VPC 内网是 900 MB/s、0.9ms。结果 Excel 出表与输入件下载都吃这条。 不能直接把 endpoint 改成内网地址:预签名 URL 的 host 必须是浏览器可达的反代入口, 否则用户侧直传当场全断。所以新增 aiimage.oss.internal-endpoint(默认空=沿用 endpoint, 行为与今天完全一致),只给服务端 I/O 的 client 用;presign 那两处改用 public-endpoint 的 client, 并把内网地址纳入 managedEndpoints,避免历史数据里出现内网 host 时不归一化。 启动打一行 [oss] 服务端读写端点=…(预签名端点=…),发版后直接回读生效值。
This commit is contained in:
+24
@@ -228,4 +228,28 @@ class OssStorageServiceTest {
|
||||
"https://download.aishufu.top/shufu-shop-data/result/shop_data_crawl/abc/out.xlsx",
|
||||
storageService.generateFreshDownloadUrl("result/shop_data_crawl/abc/out.xlsx"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void serverIoEndpointFollowsPublicEndpointWhenInternalIsAbsent() {
|
||||
assertEquals("https://oss.aishufu.top", OssStorageService.objectIoEndpoint(properties));
|
||||
assertEquals("https://oss.aishufu.top", OssStorageService.signingEndpoint(properties));
|
||||
}
|
||||
|
||||
@Test
|
||||
void internalEndpointMovesServerIoButKeepsPresignPublic() {
|
||||
properties().setInternalEndpoint(" http://192.168.0.171:9000 ");
|
||||
assertEquals("http://192.168.0.171:9000", OssStorageService.objectIoEndpoint(properties));
|
||||
assertEquals("https://oss.aishufu.top", OssStorageService.signingEndpoint(properties));
|
||||
}
|
||||
|
||||
/** 内网地址只给服务端自己用;万一有历史数据把它写进了 URL,读出来仍要归一化成公网入口。 */
|
||||
@Test
|
||||
void internalEndpointUrlsAreNormalizedToPublicEndpoint() {
|
||||
properties().setInternalEndpoint("http://192.168.0.171:9000");
|
||||
OssStorageService oss = new OssStorageService(properties);
|
||||
assertEquals(
|
||||
"https://oss.aishufu.top/nanri-ai-images/result/appearance_patent/abc/out.xlsx",
|
||||
oss.normalizeManagedPublicUrl(
|
||||
"http://192.168.0.171:9000/nanri-ai-images/result/appearance_patent/abc/out.xlsx"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user