feat: govern knowledge assets and source citations

This commit is contained in:
key
2026-08-02 01:43:43 +08:00
parent cafb836cda
commit 699cc08050
144 changed files with 17205 additions and 453 deletions
@@ -318,6 +318,28 @@ public class OssClient {
}
}
/** Streams one RFC 7233 byte range without buffering the object in application memory. */
public void downloadRange(String key, String range, OutputStream out, Consumer<GetObjectResponse> responseConsumer) {
try {
DownloadRequest.TypedBuilder<ResponsePublisher<GetObjectResponse>> typedBuilder = DownloadRequest.builder()
.responseTransformer(AsyncResponseTransformer.toPublisher())
.getObjectRequest(y -> y.bucket(properties.getBucketName()).key(key).range(range).build());
Download<ResponsePublisher<GetObjectResponse>> download = transferManager.download(typedBuilder.build());
ResponsePublisher<GetObjectResponse> publisher = download.completionFuture().join().result();
Optional.ofNullable(responseConsumer).ifPresent(consumer -> consumer.accept(publisher.response()));
try (WritableByteChannel channel = Channels.newChannel(out)) {
publisher.subscribe(buffer -> {
while (buffer.hasRemaining()) {
try { channel.write(buffer); }
catch (IOException e) { throw new RuntimeException(e); }
}
}).join();
}
} catch (Exception e) {
throw new OssException("文件范围下载失败,错误信息:[" + e.getMessage() + "]");
}
}
/**
* 删除云存储服务中指定路径下文件
*