How to access temp files in AEM?

Avatar

Avatar

vasim_akram_sha

Avatar

vasim_akram_sha

vasim_akram_sha

22-06-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

23-06-2017

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

Answers (1)

Answers (1)

Avatar

Avatar

bobkranson

Avatar

bobkranson

bobkranson

23-06-2017

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