Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Adapting a zip file

Avatar

Level 3

Hi,

I am having a package.

I need to get the package and upload to s3 bucket

I am using the following code

Resource resource = resolver.getResource(packagePath);

            File asset=resource.adaptTo(File.class);

            S3BucketConnector.uploadPackageToS3(asset);

Where package path will be /etc/packages/Query/query-1.14792.0.zip

resource is returing JcrNodeResource, type=nt:file, superType=null, path=/etc/packages/Query/query-1.14792.0.zip

After adapting asset is always null.

How to proceed with this??

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hey,

Uploading a file object and uploading package zip file is two different thing. You can transfer the data in binary format but can't upload FIle Object and be hoping that actual package would get uploaded to the destination.

Fundamentally, you need to read the zip file from JCR Node as binary data and post the same binary data to another system.

I hope this helps.

View solution in original post

2 Replies

Avatar

Level 10

Try using Java JCR logic to get the file and pass that to uploadPackageToS3(). Something like:

InputStream in = node.getNode("jcr:content").getProperty("jcr:data").getStream();

That should work.

Avatar

Correct answer by
Level 9

Hey,

Uploading a file object and uploading package zip file is two different thing. You can transfer the data in binary format but can't upload FIle Object and be hoping that actual package would get uploaded to the destination.

Fundamentally, you need to read the zip file from JCR Node as binary data and post the same binary data to another system.

I hope this helps.