Write a bundle and Jsp page call the function, it's weired that can't generate and find the file.
@Override public String generateFileTest() { File file = new File("test.xml"); file.createNewFile(); return file.getAbsolutePath(); }
Anybody know the reason? BTW, if need to set configure in AEM?
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
When writing a method in AEM that works with a File - make sure that AEM can locate the file. Typically, a file is located in the DAM and you use an AEM API to get the file. For example, QueryBuilder API. Here is a community article that shows how to write functionality in AEM that works with files. In this example, the AEM functionality returns a collection of DAM graphic files. See:
http://helpx.adobe.com/experience-manager/using/downloading-dam-assets.html
Views
Replies
Total Likes
When writing a method in AEM that works with a File - make sure that AEM can locate the file. Typically, a file is located in the DAM and you use an AEM API to get the file. For example, QueryBuilder API. Here is a community article that shows how to write functionality in AEM that works with files. In this example, the AEM functionality returns a collection of DAM graphic files. See:
http://helpx.adobe.com/experience-manager/using/downloading-dam-assets.html
Views
Replies
Total Likes
What exactly isn't working? This code should run fine on AEM.
Views
Replies
Total Likes
You can find your file by path <path_to_your_cq>\crx-quickstart\test.xml
To see and use this file in CQ you can save it to a node with a type "nt:resource" to property with name "jcr:data"
Views
Replies
Total Likes
Yes, this code run fine and no exception. But always can't find the generate file.
Views
Replies
Total Likes
So in your use case - you are simply attempting to dynamically create a file and then you want to return the path? As i pointed out - most ppl working with files in AEM, read files from the DAM and return data. In that use case - you can write a query that gets the file, and then return the location of the file:
String path = hit.getPath();
If you create a File and return the path using this method: getAbsolutePath:
Returns the absolute pathname string of this abstract pathname.
This API call inside an AEM service may not resolve to the JCR location. I would use AEM APIs to get the JCR path of a digital asset (ie -a file in AEM). For example - QueryBuilder API. Or you can use JCR API.
Likewise , you can write files to AEM. For example - a client libs location. Read this community as an example:
http://helpx.adobe.com/experience-manager/using/post_files.html
This handles files that a client app posts to AEM. So in AEM - you can create services that read and write files to AEM. Use AEM APIS not the File API.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies