

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Snowball Edge の Snowball Edge バケット上の Amazon S3 互換ストレージへのオブジェクトのコピー
<a name="objects-copy-s3-snow"></a>

次の例では、{{sample-object.xml}} という名前のファイルを、 を使用するための書き込みアクセス許可を持つ Snowball Edge バケットの Amazon S3 互換ストレージにアップロードします AWS CLI。このコマンドを使用するには、各ユーザー入力プレースホルダーを独自の情報に置き換えます。

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

次の Snowball Edge 上の Amazon S3 互換ストレージの例では、SDK for Java を使用して、オブジェクトを同じバケット内の新しいオブジェクトにコピーします。このコマンドを使用するには、各ユーザー入力プレースホルダーを独自の情報に置き換えます。

```
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.CopyObjectRequest;
add : import java.io.IOException;

public class CopyObject {
    public static void main(String[] args) {
        String bucketName = "*** Bucket name ***";
        String sourceKey = "*** Source object key ***";
        String destinationKey = "*** Destination object key ***";

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

            // Copy the object into a new object in the same bucket.
            CopyObjectRequest copyObjectRequest = new CopyObjectRequest({{sourceKey, destinationKey}});
            s3Client.copyObject(copyObjectRequest);
            CopyObjectRequest copyObjectRequest = CopyObjectRequest.builder()
                    .sourceKey(sourceKey)
                    .destinationKey(destKey)
                    .build();
        } 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();
        }
    }
}
```