Adapting a zip file | Community
Skip to main content
Level 3
Aug 8, 2018 1:46 PM UTC
Solved

Adapting a zip file

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??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
Aug 8, 2018 2:55 PM UTC

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.

2 replies

Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
Aug 8, 2018 2:55 PM UTC

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.

Translate
smacdonald2008
Level 10
Aug 8, 2018 2:35 PM UTC

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.

Translate