Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to access temp files in AEM?

Avatar

Level 2

Hi,

I am creating a temp file using following method in OSGI bundle.

Files.createTempFile("temp", ".json"); .

When I run the script in my local server it is getting created under  C:/Users/vasim/AppData/Local/Temp/temp1233433455.txt. I am accessing that file in my javaScript and doing some operations on it. I have deployed the code in UAT server. In UAT it is creating files  /opt/aem/. Now I am unable to access that file in my JavaScript. I tried by creating file under /content. Then also it is not working.

Regards,

Vasim

1 Accepted Solution

Avatar

Correct answer by
Employee

You can't access files on the filesystem through JCR, you would do that via the Java File api.

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

You can't access files on the filesystem through JCR, you would do that via the Java File api.

Avatar

Level 4

You might add -Djava.io.tmpdir=somepath to your instance so you can control the temp file location and manage it for your application.