Elencare oggetti in un bucket nello storage compatibile con Amazon S3 su Snowball Edge su Snowball Edge - AWS Snowball Edge Guida per gli sviluppatori

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Elencare oggetti in un bucket nello storage compatibile con Amazon S3 su Snowball Edge su Snowball Edge

L'esempio seguente elenca gli oggetti in uno storage compatibile con Amazon S3 sul bucket Snowball Edge utilizzando il. AWS CLI Il comando SDK è. s3-snow:ListObjectsV2 Per utilizzare questo comando, sostituisci ogni segnaposto immesso dall'utente con le tue informazioni.

aws s3api list-objects-v2 --bucket sample-bucket --endpoint-url s3api-endpoint-ip --profile your-profile

Per ulteriori informazioni su questo comando, vedere list-objects-v2 nel AWS CLI Command Reference.

Il seguente esempio di storage compatibile con Amazon S3 su Snowball Edge elenca gli oggetti in un bucket utilizzando l'SDK for Java. Per utilizzare questo comando, sostituisci ogni segnaposto immesso dall'utente con le tue informazioni.

Questo esempio utilizza la ListObjectsversione 2, che è l'ultima revisione del funzionamento dell'API. ListObjects Si consiglia di utilizzare questa operazione API rivista per lo sviluppo di applicazioni. Per la compatibilità con le versioni precedenti, Amazon S3 continua a supportare la versione precedente di questa operazione API.

import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.ListObjectsV2Request; import com.amazonaws.services.s3.model.ListObjectsV2Result; import com.amazonaws.services.s3.model.S3ObjectSummary; public class ListObjectsV2 { public static void main(String[] args) { String bucketName = "*** Bucket name ***"; try { // This code expects that you have AWS credentials set up per: // https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html AmazonS3 s3Client = AmazonS3ClientBuilder.standard() .enableUseArnRegion() .build(); System.out.println("Listing objects"); // maxKeys is set to 2 to demonstrate the use of // ListObjectsV2Result.getNextContinuationToken() ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(bucketName).withMaxKeys(2); ListObjectsV2Result result; do { result = s3Client.listObjectsV2(req); for (S3ObjectSummary objectSummary : result.getObjectSummaries()) { System.out.printf(" - %s (size: %d)\n", objectSummary.getKey(), objectSummary.getSize()); } // If there are more than maxKeys keys in the bucket, get a continuation token // and list the next objects. String token = result.getNextContinuationToken(); System.out.println("Next Continuation Token: " + token); req.setContinuationToken(token); } while (result.isTruncated()); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it, so it returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }