On Fri, Nov 7, 2014 at 7:38 AM,  <ningji...@apache.org> wrote:
> Repository: camel
> Updated Branches:
>   refs/heads/master 4fa9ef24e -> ff87129bf
>
>
> CAMEL-8006 S3Producer should use File to upload directly
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ff87129b
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ff87129b
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ff87129b
>
> Branch: refs/heads/master
> Commit: ff87129bf08548e1f1825f2fcd90cb7dee37ca27
> Parents: 4fa9ef2
> Author: Willem Jiang <willem.ji...@gmail.com>
> Authored: Fri Nov 7 14:37:52 2014 +0800
> Committer: Willem Jiang <willem.ji...@gmail.com>
> Committed: Fri Nov 7 14:37:52 2014 +0800
>
> ----------------------------------------------------------------------
>  .../java/org/apache/camel/component/aws/s3/S3Producer.java   | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/ff87129b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
> ----------------------------------------------------------------------
> diff --git 
> a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
>  
> b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
> index 38db307..4d6f3ae 100644
> --- 
> a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
> +++ 
> b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Producer.java
> @@ -167,11 +167,15 @@ public class S3Producer extends DefaultProducer {
>
>          File filePayload = null;
>          Object obj = exchange.getIn().getMandatoryBody();
> +        PutObjectRequest putObjectRequest = null;
>          if (obj instanceof File) {
>              filePayload = (File) obj;
> -        }

Hi

I think the Camel file component may wrap the body as a WrappedFile
instance etc. So you may need to add check for that too

        if (!allowFiles) {
            if (obj instanceof WrappedFile || obj instanceof File) {
                return prepend + "[Body is file based: " + obj + "]";
            }
        }

So you need to check for that and then call getFile to get the actual
file, eg pseudo code

if (body is wrapped file)
   body = wrapped file . getFile()
}

if (body is file) {
   ...
}



> -        PutObjectRequest putObjectRequest = new 
> PutObjectRequest(getConfiguration().getBucketName(),
> +            // submit the request without loading it into memory
> +            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) {
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to