Todos os produtos
Search
Central de documentação

Object Storage Service:Determine whether an object exists (Android SDK)

Última atualização: Jul 03, 2026

O SDK do Object Storage Service (OSS) para Android oferece uma API síncrona prática para verificar se um objeto específico existe em um bucket.

Observações de uso

Exemplos

O código de exemplo a seguir mostra como verificar se um objeto chamado exampleobject.txt existe em um bucket denominado examplebucket:

try {
     // Specify the name of the bucket and the full path of the object. In this example, the bucket name is examplebucket and the full path of the object is exampledir/exampleobject.txt. Do not include the bucket name in the full path.
    if (oss.doesObjectExist("examplebucket", "exampledir/exampleobject.txt")) {
        Log.d("doesObjectExist", "object exist.");
    } else {
        Log.d("doesObjectExist", "object does not exist.");
    }
} catch (ClientException e) {
    // Handle client exceptions, such as network exceptions.
    e.printStackTrace();
} catch (ServiceException e) {
    // Handle service exceptions.
    Log.e("ErrorCode", e.getErrorCode());
    Log.e("RequestId", e.getRequestId());
    Log.e("HostId", e.getHostId());
    Log.e("RawMessage", e.getRawMessage());
}

Referências