Adapting a zip file | Community
Skip to main content
Level 3
August 8, 2018
Solved

Adapting a zip file

  • August 8, 2018
  • 2 replies
  • 1786 views

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.
Best answer by Jitendra_S_Toma

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

smacdonald2008
Level 10
August 8, 2018

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.

Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
August 8, 2018

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.