Package com.amazonaws.services.s3.model

Examples of com.amazonaws.services.s3.model.PutObjectRequest


        ObjectMetadata objectMetadata = determineMetadata(exchange);

        File filePayload = null;
        Object obj = exchange.getIn().getMandatoryBody();
        PutObjectRequest putObjectRequest = null;
        // Need to check if the message body is WrappedFile
        if (obj instanceof WrappedFile) {
            obj = ((WrappedFile<?>)obj).getFile();
        }
        if (obj instanceof File) {
            filePayload = (File) obj;
            putObjectRequest = new PutObjectRequest(getConfiguration().getBucketName(), determineKey(exchange), filePayload);
        } else {
            putObjectRequest = new PutObjectRequest(getConfiguration().getBucketName(),
                determineKey(exchange), exchange.getIn().getMandatoryBody(InputStream.class), objectMetadata);
        }

        String storageClass = determineStorageClass(exchange);
        if (storageClass != null) {
            putObjectRequest.setStorageClass(storageClass);
        }

        String cannedAcl = exchange.getIn().getHeader(S3Constants.CANNED_ACL, String.class);
        if (cannedAcl != null) {
            CannedAccessControlList objectAcl = CannedAccessControlList.valueOf(cannedAcl);
            putObjectRequest.setCannedAcl(objectAcl);
        }

        AccessControlList acl = exchange.getIn().getHeader(S3Constants.ACL, AccessControlList.class);
        if (acl != null) {
            // note: if cannedacl and acl are both specified the last one will be used. refer to
            // PutObjectRequest#setAccessControlList for more details
            putObjectRequest.setAccessControlList(acl);
        }
        LOG.trace("Put object [{}] from exchange [{}]...", putObjectRequest, exchange);

        PutObjectResult putObjectResult = getEndpoint().getS3Client().putObject(putObjectRequest);

        LOG.trace("Received result [{}]", putObjectResult);

        Message message = getMessageForResponse(exchange);
        message.setHeader(S3Constants.E_TAG, putObjectResult.getETag());
        if (putObjectResult.getVersionId() != null) {
            message.setHeader(S3Constants.VERSION_ID, putObjectResult.getVersionId());
        }

        if (getConfiguration().isDeleteAfterWrite() && filePayload != null) {
            IOHelper.close(putObjectRequest.getInputStream());
            FileUtil.deleteFile(filePayload);
        }
    }
View Full Code Here


        Date lastModified = exchange.getIn().getHeader(S3Constants.LAST_MODIFIED, Date.class);
        if (lastModified != null) {
            objectMetadata.setLastModified(lastModified);
        }
       
        PutObjectRequest putObjectRequest = new PutObjectRequest(
                getConfiguration().getBucketName(),
                determineKey(exchange),
                exchange.getIn().getMandatoryBody(InputStream.class),
                objectMetadata);

        String storageClass = determineStorageClass(exchange);
        if (storageClass != null) {
            putObjectRequest.setStorageClass(storageClass);
        }

        LOG.trace("Put object [{}] from exchange [{}]...", putObjectRequest, exchange);
       
        PutObjectResult putObjectResult = getEndpoint().getS3Client().putObject(putObjectRequest);
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
       
        assertResponseMessage(exchange.getIn());
    }
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
       
        assertResponseMessage(exchange.getOut());
    }
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("STANDARD", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
        assertEquals(2L, putObjectRequest.getMetadata().getContentLength());
        assertEquals("text/html", putObjectRequest.getMetadata().getContentType());
        assertEquals("no-cache", putObjectRequest.getMetadata().getCacheControl());
        assertEquals("attachment;", putObjectRequest.getMetadata().getContentDisposition());
        assertEquals("gzip", putObjectRequest.getMetadata().getContentEncoding());
        assertEquals("TWF", putObjectRequest.getMetadata().getContentMD5());
        assertEquals(now, putObjectRequest.getMetadata().getLastModified());
       
        assertResponseMessage(exchange.getIn());
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.amazonaws.services.s3.AmazonS3#putObject(java.lang.String, java.lang.String, java.io.File)
     */
    public PutObjectResult putObject(String bucketName, String key, File file)
            throws AmazonClientException, AmazonServiceException {
        return putObject(new PutObjectRequest(bucketName, key, file)
            .withMetadata(new ObjectMetadata()));
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.amazonaws.services.s3.AmazonS3#putObject(java.lang.String, java.lang.String, java.io.InputStream, com.amazonaws.services.s3.model.S3ObjectMetadata)
     */
    public PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata)
            throws AmazonClientException, AmazonServiceException {
        return putObject(new PutObjectRequest(bucketName, key, input, metadata));
    }
View Full Code Here

     *             If any errors occurred in Amazon S3 while processing the
     *             request.
     */
    public Upload upload(final String bucketName, final String key, final InputStream input, ObjectMetadata objectMetadata)
        throws AmazonServiceException, AmazonClientException {
        return upload(new PutObjectRequest(bucketName, key, input, objectMetadata));
    }
View Full Code Here

     *             If any errors occurred in Amazon S3 while processing the
     *             request.
     */
    public Upload upload(final String bucketName, final String key, final File file)
        throws AmazonServiceException, AmazonClientException {
        return upload(new PutObjectRequest(bucketName, key, file));
    }
View Full Code Here

                if(metadataProvider!=null){
                    metadataProvider.provideObjectMetadata(f,metadata);
                }
               
                uploads.add((UploadImpl) upload(
                        new PutObjectRequest(bucketName, virtualDirectoryKeyPrefix + key, f).withMetadata(metadata).withGeneralProgressListener(listener),
                        stateChangeListener));
            }
        }

        transferProgress.setTotalBytesToTransfer(totalSize);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.s3.model.PutObjectRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.