tencent cloud

Smart Media Hosting

Java Call

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 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;
});


Ajuda e Suporte

Esta página foi útil?

comentários