En este tema se describe cómo listar todos los objetos, una cantidad específica de objetos y aquellos cuyo nombre contiene un prefijo determinado dentro de un bucket de Object Storage Service (OSS).
Notas de uso
En este tema se utiliza el endpoint público de la región China (Hangzhou). Si necesita acceder a OSS desde otros servicios de Alibaba Cloud en la misma región, utilice un endpoint interno. Para más información sobre las regiones y los endpoints compatibles, consulte Regions and endpoints.
Aquí se muestra cómo crear una instancia de OSSClient con un endpoint de OSS. Para conocer configuraciones alternativas, como usar un dominio personalizado o autenticarse con credenciales de Security Token Service (STS), consulte Create an OssClient.
Para listar objetos, debe contar con el permiso
oss:ListObjects. Para más información, consulte Attach a custom policy to a RAM user.
Listar objetos
Llame al método listObjects o listObjectsV2 para listar los objetos del directorio raíz de un bucket específico. Los subdirectorios y los objetos que contienen no se incluyen en el resultado.
-
Uso del método listObjects
A continuación se muestra cómo llamar al método listObjects para listar los objetos del directorio raíz de un bucket llamado examplebucket. Los subdirectorios y sus objetos no se incluyen. De forma predeterminada, se devuelven 100 objetos.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\Core\OssException; try { // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $listObjectInfo = $ossClient->listObjects($bucket); printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); printf("Marker: %s". "\n",$listObjectInfo->getMarker()); printf("Next Marker: %s". "\n",$listObjectInfo->getNextMarker()); printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { printf("Object Name: %s". "\n",$objectInfo->getKey()); printf("Object Size: %s". "\n",$objectInfo->getSize()); printf("Object Type: %s". "\n",$objectInfo->getType()); printf("Object ETag: %s". "\n",$objectInfo->getETag()); printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); if ($objectInfo->getRestoreInfo()){ printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); } if($objectInfo->getOwner()){ printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); } } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); } } } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } -
Método listObjectsV2
El siguiente código muestra cómo utilizar el método listObjectsV2 para listar los objetos del directorio raíz de un bucket llamado examplebucket. Esta operación no lista los subdirectorios ni los objetos que contienen. De forma predeterminada, se devuelven hasta 100 objetos.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\Core\OssException; try { // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $listObjectInfo = $ossClient->listObjectsV2($bucket); printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); printf("Next Continuation Token: %s". "\n",$listObjectInfo->getNextContinuationToken()); printf("Continuation Token: %s". "\n",$listObjectInfo->getContinuationToken()); printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); printf("Key Count: %s". "\n",$listObjectInfo->getKeyCount()); printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); printf("Start After: %s". "\n",$listObjectInfo->getStartAfter()); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { printf("Object Name: %s". "\n",$objectInfo->getKey()); printf("Object Size: %s". "\n",$objectInfo->getSize()); printf("Object Type: %s". "\n",$objectInfo->getType()); printf("Object ETag: %s". "\n",$objectInfo->getETag()); printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); if ($objectInfo->getRestoreInfo()){ printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); } if($objectInfo->getOwner()){ printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); } } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); } } } catch (OssException $e) { printf($e->getMessage() . "\n"); return; }
Listar una cantidad específica de objetos
Llame al método listObjects o listObjectsV2 para listar una cantidad determinada de objetos en un bucket.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar 200 objetos en un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the maximum number of objects to return to 200. $maxkeys = 200; $options = array( 'max-keys' => $maxkeys, ); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar 200 objetos en un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the maximum number of objects to return to 200. $maxkeys = 200; $options = array( 'max-keys' => $maxkeys, ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } }
Listar objetos con un prefijo específico
Llame al método listObjects o listObjectsV2 para listar los objetos de un bucket que coincidan con un prefijo determinado.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar los objetos con el prefijo
diren un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the prefix to dir/. $prefix = 'dir/'; $options = array( 'prefix' => $prefix, ); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar los objetos con el prefijo
diren un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the prefix to dir/. $prefix = 'dir/'; $options = array( 'prefix' => $prefix, ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } }
Listar objetos posteriores alfabéticamente a un nombre de objeto específico
Llame al método listObjects o listObjectsV2 para listar los objetos que se encuentren después de un nombre de objeto específico en orden alfabético.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar los objetos posteriores a
test.txten orden alfabético dentro de un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set marker to test.txt. This parameter specifies that objects are returned in alphabetical order starting from the object specified by marker. $marker = "test.txt"; $options = array( OssClient::OSS_MARKER=>$marker ); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar los objetos posteriores a
test.txten orden alfabético dentro de un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set startAfter to test.txt. This parameter specifies that objects are returned in alphabetical order starting from the object specified by startAfter. $startAfter = "test.txt"; $options = array( OssClient::OSS_START_AFTER=>$startAfter ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); } catch (OssException $e) { printf($e->getMessage() . "\n"); return; } $objectList = $listObjectInfo->getObjectList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } }
Listar todos los objetos por página
Llame al método listObjects o listObjectsV2 para listar todos los objetos de manera paginada. Utilice el parámetro maxKeys para especificar la cantidad de objetos que se devolverán en cada página.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar de forma paginada todos los objetos de un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( // Set the number of objects to return on each page to 200. OssClient::OSS_MAX_KEYS=>200 ); do{ $result = $ossClient->listObjects($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } $options[OssClient::OSS_MARKER] = $result->getNextMarker(); }while($result->getIsTruncated() === 'true'); -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar de forma paginada todos los objetos de un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( // Set the number of objects to return on each page to 200. OssClient::OSS_MAX_KEYS=>200 ); do{ $result = $ossClient->listObjectsV2($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } $options[OssClient::OSS_CONTINUATION_TOKEN] = $result->getNextContinuationToken(); }while($result->getIsTruncated() === 'true');
Listar objetos con un prefijo específico por página
Llame al método listObjects o listObjectsV2 para listar de manera paginada los objetos que coincidan con un prefijo determinado.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar de forma paginada los objetos con el prefijo
diren un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the number of objects to return on each page to 100. $maxKeys = 100; // Specify the prefix. Example: dir/. $prefix = 'dir/'; $options = array( OssClient::OSS_MAX_KEYS =>$maxKeys, OssClient::OSS_PREFIX =>$prefix ); do{ $result = $ossClient->listObjects($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } $options[OssClient::OSS_MARKER] = $result->getNextMarker(); }while($result->getIsTruncated() === 'true'); -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar de forma paginada los objetos con el prefijo
diren un bucket llamado examplebucket.<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the number of objects to return on each page to 100. $maxKeys = 100; // Specify the prefix. Example: dir/. $prefix = 'dir/'; $options = array( OssClient::OSS_MAX_KEYS =>$maxKeys, OssClient::OSS_PREFIX =>$prefix ); do{ $result = $ossClient->listObjectsV2($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } $options[OssClient::OSS_CONTINUATION_TOKEN] = $result->getNextContinuationToken(); }while($result->getIsTruncated() === 'true');
Especificar la codificación de los nombres de objeto
Si el nombre de un objeto contiene caracteres especiales, debe codificarlo antes de transmitirlo. OSS solo es compatible con la codificación URL.
Comillas simples (')
Comillas dobles (")
Signos et (&)
Signos de mayor que y menor que (< >)
Comas de enumeración (、)
Caracteres chinos
Llame al método listObjects o listObjectsV2 para especificar la codificación de los nombres de objeto.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para especificar la codificación de los nombres de objeto.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( // Set the encoding type of object names to URL. OssClient::OSS_ENCODING_TYPE=>'url', // Set the number of objects to return on each page to 20. OssClient::OSS_MAX_KEYS=>20 ); do{ $result = $ossClient->listObjects($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } print("prefix:\n"); $prefixList = $result->getPrefixList(); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } if($result->getDelimiter() != null){ printf("delimiter:".$result->getDelimiter().PHP_EOL); } if($result->getMarker() != null){ printf("marker:".$result->getMarker().PHP_EOL); } $options[OssClient::OSS_MARKER] = $result->getNextMarker(); }while($result->getIsTruncated() === 'true'); -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para especificar la codificación de los nombres de objeto.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( // Set the encoding type of object names to URL. OssClient::OSS_ENCODING_TYPE=>'url', // Set the number of objects to return on each page to 20. OssClient::OSS_MAX_KEYS=>20 ); do{ $result = $ossClient->listObjectsV2($bucket,$options); $objectList = $result->getObjectList(); print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } print("prefix:\n"); $prefixList = $result->getPrefixList(); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } if($result->getDelimiter() != null){ printf("delimiter:".$result->getDelimiter().PHP_EOL); } if($result->getStartAfter() != null){ printf("start after:".$result->getStartAfter().PHP_EOL); } $options[OssClient::OSS_CONTINUATION_TOKEN] = $result->getNextContinuationToken(); }while($result->getIsTruncated() === 'true');
Simular directorios
OSS utiliza una estructura plana en la que todos los datos se almacenan como objetos. Para simular un directorio, cree un objeto de 0 bytes cuyo nombre termine con una barra diagonal (/). Este objeto se puede cargar y descargar. La consola de OSS muestra los objetos cuyos nombres terminan con una barra diagonal (/) como directorios.
Para listar objetos por directorio, especifique los parámetros delimiter y prefix.
Si establece prefix con el nombre de un directorio en la solicitud, se listan los objetos y subdirectorios cuyos nombres contienen ese prefijo.
Si especifica un prefijo y establece delimiter con una barra diagonal (/) en la solicitud, se listan los objetos y subdirectorios del directorio cuyos nombres comienzan con el prefijo indicado. Cada subdirectorio aparece como un único elemento de resultado en CommonPrefixes. Los objetos y directorios dentro de estos subdirectorios no se listan.
Por ejemplo, suponga que un bucket contiene los siguientes objetos: oss.jpg, fun/test.jpg, fun/movie/001.avi y fun/movie/007.avi. Se especifica la barra diagonal (/) como delimitador de directorios. A continuación se describe cómo listar objetos en directorios simulados.
Listar todos los objetos de un bucket
Llame al método listObjects o listObjectsV2 para listar todos los objetos de un bucket específico.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar todos los objetos de un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( 'delimiter' => '', ); try { $listObjectInfo = $ossClient->listObjects($bucket,$options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar todos los objetos de un bucket llamado examplebucket.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); $options = array( 'delimiter' => '', ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket,$options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Respuesta
La siguiente respuesta se devuelve cuando llama a los métodos anteriores para listar todos los objetos del bucket examplebucket.
objectList: fun/movie/001.avi fun/movie/007.avi fun/test.jpg oss.jpg
Listar todos los objetos de un directorio específico
Llame al método listObjects o listObjectsV2 para listar todos los objetos del directorio fun/.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar todos los objetos del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory to fun/. $prefix = 'fun/'; $options = array( 'prefix' => $prefix, 'delimiter' => '', ); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar todos los objetos del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory name to fun/. $prefix = 'fun/'; $options = array( 'prefix' => $prefix, 'delimiter' => '', ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Resultados
La siguiente respuesta se devuelve cuando llama a los métodos anteriores para listar todos los objetos del directorio fun/.
objectList: fun/movie/001.avi fun/movie/007.avi fun/test.jpg
Listar objetos y subdirectorios de un directorio
Llame al método listObjects o listObjectsV2 para listar los objetos y subdirectorios del directorio fun/.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para listar los objetos y subdirectorios del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory name to fun/. $prefix = 'fun/'; $delimiter = '/'; $options = array( 'delimiter' => $delimiter, 'prefix' => $prefix, ); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } // The commonPrefixs list contains all subdirectories in the fun/ directory. if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para listar los objetos y subdirectorios del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory name to fun/. $prefix = 'fun/'; $delimiter = '/'; $options = array( 'delimiter' => $delimiter, 'prefix' => $prefix, ); try { $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); $objectList = $listObjectInfo->getObjectList(); $prefixList = $listObjectInfo->getPrefixList(); if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { print($objectInfo->getKey() . "\n"); } } // The commonPrefixs list contains all subdirectories in the fun/ directory. if (!empty($prefixList)) { print("prefixList: \n"); foreach ($prefixList as $prefixInfo) { print($prefixInfo->getPrefix() . "\n"); } } -
Valor devuelto
La siguiente respuesta se devuelve cuando llama a los métodos anteriores para listar los objetos y subdirectorios del directorio fun/.
objectList: fun/test.jpg prefixList: fun/movie/
Obtener el tamaño de los objetos de un directorio específico
Llame al método listObjects o listObjectsV2 para obtener el tamaño de los objetos del directorio fun/.
-
Uso del método listObjects
El siguiente código muestra cómo llamar al método listObjects para obtener el tamaño de los objetos del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory name to fun/. $prefix = 'fun/'; $delimiter = ''; $nextMarker = ''; $maxkeys = 1000; $options = array( 'delimiter' => $delimiter, 'prefix' => $prefix, 'max-keys' => $maxkeys, 'marker' => $nextMarker, ); $bool = true; $size = 0; while ($bool){ $result = $ossClient->listObjects($bucket,$options); foreach ($result->getObjectList() as $objInfo){ printf("object name".$objInfo->getKey().":" . ($objInfo->getSize() / 1024) . "KB".PHP_EOL); $size+=$objInfo->getSize(); } if($result->getIsTruncated() === 'true'){ $options['marker'] = $result->getNextMarker(); }else{ $bool = false; } } printf($prefix.":" . ($size / 1024) . "KB".PHP_EOL); -
Uso del método listObjectsV2
El siguiente código muestra cómo llamar al método listObjectsV2 para obtener el tamaño de los objetos del directorio fun/.
<?php if (is_file(__DIR__ . '/../autoload.php')) { require_once __DIR__ . '/../autoload.php'; } if (is_file(__DIR__ . '/../vendor/autoload.php')) { require_once __DIR__ . '/../vendor/autoload.php'; } require_once __DIR__ . '/Common.php'; use OSS\Credentials\EnvironmentVariableCredentialsProvider; use OSS\OssClient; use OSS\CoreOssException; // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. $provider = new EnvironmentVariableCredentialsProvider(); // The following example uses the endpoint of the China (Hangzhou) region. Replace the endpoint with the actual endpoint. $endpoint = "https://oss-cn-hangzhou.aliyuncs.com"; // Specify the bucket name. Example: examplebucket. $bucket= "examplebucket"; $config = array( "provider" => $provider, "endpoint" => $endpoint, "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4, "region"=> "cn-hangzhou" ); $ossClient = new OssClient($config); // Set the directory name to fun/. $prefix = 'fun/'; $delimiter = ''; $nextMarker = ''; $maxkeys = 1000; $options = array( 'delimiter' => $delimiter, 'prefix' => $prefix, 'max-keys' => $maxkeys, ); $bool = true; $size = 0; while ($bool){ $result = $ossClient->listObjectsV2($bucket,$options); foreach ($result->getObjectList() as $objInfo){ printf("object name".$objInfo->getKey().":" . ($objInfo->getSize() / 1024) . "KB".PHP_EOL); $size+=$objInfo->getSize(); } if($result->getIsTruncated() === 'true'){ $options[OssClient::OSS_CONTINUATION_TOKEN] = $result->getNextContinuationToken(); }else{ $bool = false; } } printf($prefix.":" . ($size / 1024) . "KB".PHP_EOL); -
Valor devuelto
La siguiente respuesta se devuelve cuando llama a los métodos anteriores para obtener el tamaño de los objetos.
object namefun/movie/001.avi:0.01953125KB object namefun/movie/007.avi:290.71875KB object namefun/test.jpg:144.216796875KB fun/:434.955078125KB
Referencias
Para consultar el código de ejemplo completo sobre cómo listar objetos, consulte el ejemplo de GitHub.
Para obtener más información sobre las operaciones de API que puede llamar para listar objetos, consulte GetBucket (ListObjects) y ListObjectsV2 (GetBucketV2).