Adapting a zip file

sr508 08-08-2018

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

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_S_Toma 08-08-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.

Answers (1)

Answers (1)

smacdonald2008 08-08-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.