List of usage examples for com.amazonaws.services.s3.model PutObjectResult setVersionId
@Override public void setVersionId(String versionId)
From source file:com.kolich.aws.services.s3.impl.KolichS3Client.java
License:Open Source License
@Override public Either<HttpFailure, PutObjectResult> putObject(final String bucketName, final boolean rrs, final ContentType type, final InputStream input, final long contentLength, final String... path) { return new AwsS3HttpClosure<PutObjectResult>(client_, SC_OK, bucketName) { @Override//from ww w . j a v a 2s . c om public void validate() throws Exception { checkNotNull(bucketName, "Bucket name cannot be null."); checkState(isValidBucketName(bucketName), "Invalid bucket name, " + "did not match expected bucket name pattern."); } @Override public void prepare(final AwsHttpRequest request) throws Exception { final HttpRequestBase base = request.getRequestBase(); if (rrs) { base.setHeader(STORAGE_CLASS, S3_REDUCED_REDUNDANCY); } // Although InputStreamEntity lets you specify a Content-Type, // we're intentionally forcing the issue here. It seems that // setting the content type on the request through a vanilla // InputStreamEntity does not actually do the right thing. if (type != null) { base.setHeader(CONTENT_TYPE, type.toString()); } ((HttpPut) base).setEntity(new InputStreamEntity(input, contentLength)); } @Override public PutObjectResult success(final HttpSuccess success) throws Exception { final PutObjectResult result = new PutObjectResult(); result.setETag(success.getETag()); result.setVersionId(success.getFirstHeader(S3_VERSION_ID)); return result; } }.put(path); }