Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to use JQuery or JS to download file from AEM workspace path

Avatar

Not applicable

Hi there,

There is a download file case: the files created and stored by OSGI bundle on path:

{CQ5-HOME}\sourcefile\1.xml

Now i need to use JQuery or JS in JSP page to download from the above CQ5 server path,

then post to another romote server.

[img]file.png[/img]

Anyone know how to deal with that? Please comment on here.

Thanks a lot in advance.

 

Best regards,

Brian

1 Accepted Solution

Avatar

Correct answer by
Level 10

To download a file from AEM, you can write a custom Sling Servlet to download it as part of a GET operation. TO see an example of this -- read this community article:

http://helpx.adobe.com/experience-manager/using/downloading-dam-assets.html

This article shows you how to download a ZIP that contains DAM assets as an example. 

Now to get a file to another server - you can use FTP by once again building a custom AEM service. We have this use case too within an AEM community article:

 http://helpx.adobe.com/experience-manager/using/developing-cq-application-uses-ftp.html

Note that for downloading and sending a file to another server - you do not use JQuery to build the application logic. Rather you use an OSGi bundle. You can use JQuery however to send the Sling Servelt an AJAX request. 

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

To download a file from AEM, you can write a custom Sling Servlet to download it as part of a GET operation. TO see an example of this -- read this community article:

http://helpx.adobe.com/experience-manager/using/downloading-dam-assets.html

This article shows you how to download a ZIP that contains DAM assets as an example. 

Now to get a file to another server - you can use FTP by once again building a custom AEM service. We have this use case too within an AEM community article:

 http://helpx.adobe.com/experience-manager/using/developing-cq-application-uses-ftp.html

Note that for downloading and sending a file to another server - you do not use JQuery to build the application logic. Rather you use an OSGi bundle. You can use JQuery however to send the Sling Servelt an AJAX request. 

Avatar

Not applicable

And i am wondering what the type of the nodes under the path car, e.g., "car1.png,  car11.png ....". 

But i directly put image "1.gif, 2.gif"  onto the path rather than define a node type to store image.

Looks like the above exception occurred because you did not have content in the ZIP file. Make sure that you place at least one file in it. 

Avatar

Not applicable

Hi scott, thank you so much for reply, quite helpful. But my AEM server happened exception:

java.util.zip.ZipException: ZIP file must have at least one entry
at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304) at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:140) at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321) at com.adobe.cq.sling.DownLoadFile.zipFiles(DownLoadFile.java:168) at com.adobe.cq.sling.DownLoadFile.doGet(DownLoadFile.java:102) at org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:268) at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:139) at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344) at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:511) at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:146) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:357) at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:166) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:284) at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.adobe.granite.requests.logging.impl.RequestLoggerImpl.doFilter(RequestLoggerImpl.java:124) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.adobe.cq.social.commons.security.SaferSlingPostServlet.doFilter(SaferSlingPostServlet.java:121) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl.doFilter(AuthoringUIModeServiceImpl.java:349) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.warp.TimeWarpFilter.doFilter(TimeWarpFilter.java:106) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter.doFilter(RedirectFilter.java:295) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)

 

The different between article and my code is :

map.put("path", "/content/dam/cart"); map.put("property.value", "image/gif"); 

[img]666666.png[/img]

Avatar

Level 10

Try putting the image files in the DAM as shown in the article. Once you do that - it will work like it does in the article. 

Avatar

Level 1

in my AEM project, there are some files that are exceeding the 1Gb size. when I try to download that >1Gb file then I got the network error and did not successful download 

 

below 1GB file get succefully downloaded but for >1Gb files its giving error so can you give me the solution for that problem