Skip to content

Instantly share code, notes, and snippets.

@bageljp
Last active December 12, 2015 06:38
Show Gist options
  • Save bageljp/f1bb6b7c5f096fc02803 to your computer and use it in GitHub Desktop.
Save bageljp/f1bb6b7c5f096fc02803 to your computer and use it in GitHub Desktop.
public PutObjectResult put(String key, InputStream input, long length) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(length);
objectMetadata.setContentType("image/gif");
PutObjectRequest request = new PutObjectRequest(this.bucket, key, input, objectMetadata);
request.withCannedAcl(CannedAccessControlList.PublicRead);
log.info("S3にファイルをアップロードします… bucket:" + this.bucket + "\tkey:" + key);
PutObjectResult result = this.s3Client.putObject(request);
log.info("S3にファイルをアップロードしました。 bucket:" + this.bucket + "\tkey:" + key);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment