View a markdown version of this page

将对象复制到 Snowball Edge 上 Snowball Edge 存储桶上与 Amazon S3 兼容的存储空间 - Amazon Snowball Edge 开发人员指南
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

Amazon Snowball Edge 不再向新客户提供。新客户应探索Amazon DataSync在线传输、用于安全物理传输Amazon 的数据传输终端或 Amazon 合作伙伴解决方案。对于边缘计算,请浏览 Amazon Out posts。

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

将对象复制到 Snowball Edge 上 Snowball Edge 存储桶上与 Amazon S3 兼容的存储空间

以下示例将名为的文件上传sample-object.xml到您拥有写入权限的 Snowball Edge 存储桶上的 Amazon S3 兼容存储空间。 Amazon 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 的存储示例使用适用于 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(); } } }