Recupero di un oggetto da 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à.

Recupero di un oggetto da un bucket nello storage compatibile con Amazon S3 su Snowball Edge su Snowball Edge

L'esempio seguente ottiene un oggetto denominato sample-object.xml da uno storage compatibile con Amazon S3 sul bucket Snowball Edge utilizzando il. AWS CLI Il comando SDK è. s3-snow:GetObject Per utilizzare questo comando, sostituisci ogni segnaposto immesso dall'utente con le tue informazioni.

aws s3api get-object --bucket sample-bucket --key sample-object.xml --endpoint-url s3api-endpoint-ip --profile your-profile

Per ulteriori informazioni su questo comando, vedere get-object nel Command Reference.AWS CLI

Il seguente esempio di storage compatibile con Amazon S3 su Snowball Edge ottiene un oggetto utilizzando l'SDK for Java. Per utilizzare questo comando, sostituisci ogni segnaposto immesso dall'utente con le tue informazioni. Per ulteriori informazioni, consulta GetObject in Amazon Simple Storage Service API Reference (Guida di riferimento per l'API di Amazon Simple Storage Service).

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.GetObjectRequest; import com.amazonaws.services.s3.model.ResponseHeaderOverrides; import com.amazonaws.services.s3.model.S3Object; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class GetObject { public static void main(String[] args) throws IOException { String bucketName = "*** Bucket name ***"; String key = "*** Object key ***"; S3Object fullObject = null, objectPortion = null, headerOverrideObject = null; 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(); GetObjectRequest getObjectRequest = GetObjectRequest.builder() .bucket(bucketName) .key(key) .build()); s3Client.getObject(getObjectRequest); } 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(); } finally { // To ensure that the network connection doesn't remain open, close any open input streams. if (fullObject != null) { fullObject.close(); } if (objectPortion != null) { objectPortion.close(); } if (headerOverrideObject != null) { headerOverrideObject.close(); } } } private static void displayTextInputStream(InputStream input) throws IOException { // Read the text input stream one line at a time and display each line. BufferedReader reader = new BufferedReader(new InputStreamReader(input)); String line = null; while ((line = reader.readLine()) != null) { System.out.println(line); } System.out.println(); } }