

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Snowball Edge의 Snowball Edge에 있는 Amazon S3 호환 스토리지의 버킷에서 객체 가져오기
<a name="objects-get-s3-snow"></a>

다음 예제에서는를 사용하여 Snowball Edge 버킷의 Amazon S3 호환 스토리지에서 {{sample-object.xml}}이라는 객체를 가져옵니다 AWS CLI. SDK 명령은 `s3-snow:GetObject`입니다. 이 명령을 사용하려면 각각의 사용자 입력 자리 표시자를 사용자의 정보로 바꿉니다.

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

이 명령에 대한 자세한 내용은 [AWS CLI Command Reference](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/get-object.html)의 *get-object* 섹션을 참조하세요.

다음 Amazon S3 compatible storage on Snowball Edge 예제에서는 Java용 SDK를 사용하여 객체를 가져옵니다. 이 명령을 사용하려면 각 사용자 입력 자리 표시자를 사용자의 정보로 대체합니다. 자세한 내용은 [Amazon Simple Storage Service API Reference](https://docs.aws.amazon.com/AmazonS3/latest/API/)의 [GetObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html) 섹션을 참조하세요.

```
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();
    }
}
```