tencent cloud

Smart Media Hosting

Java Call

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-01-07 11:03:11

Introduction

This document provides instructions about using the Java language to call the SMH SDK.

SMHCollectionFuture

SMHCollectionFuture is the encapsulation class of the SMH resource library, offering APIs suitable for the Java8 CompletableFuture style. All methods in SMHCollection have corresponding CompletableFuture-style methods with the same name, parameters, and return value (CompletableFuture<XXX>).

Example Code

// Generate an SMHCollectionFuture example
Context context;
SMHCollectionFuture smh = new SMHCollection(
context,
new MySMHSimpleUser()
).future();

//Get directory list
CompletableFuture<DirectoryContents> cf = smh.list(1, 50);
//Block and get result
// try {
// DirectoryContents directoryContents = cf.get();
// } catch (Throwable e){
// e.printStackTrace();
// }

//Asynchronously fetch result
// If execution successful:
cf.thenApply((result) -> {
DirectoryContents directoryContents = result;
return result;
});
// If execution exception:
cf.exceptionally((e) -> {
e.printStackTrace();
return null;
});


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백