在Amazon S3中更新现有对象与首先创建对象没有什么不同,即,使用相同的PUT
Object操作上载对象,并将覆盖现有对象(如果不受其他方式的保护,例如通过使用存储桶策略或对象版本控制)
您可以在使用适用于Java的AWS开发工具包上载对象中找到完整的代码示例,主要部分可以归结为:
AmazonS3 s3client = new AmazonS3Client(new PropertiesCredentials( S3Sample.class.getResourceAsStream( "AwsCredentials.properties")));try { System.out.println("Uploading a new object to S3 from a filen"); File file = new File(uploadFileName); s3client.putObject(new PutObjectRequest( bucketName, keyName, file)); } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which " + "means your request made it " + "to Amazon S3, but was rejected with an error response" + " for some reason."); // ... error handling based on exception details}


