Save file Serverside to dir

Posted by Jorrit on 02-Jun-2016 08:58

Hi,

Can anybody help me how to save a file (xml document) serverside(trigger) to directory in network?

working with Privatecloud V 4.1.1.0

Regards Jorrit

Posted by Shiva Duriseati on 02-Jun-2016 11:39

Hi Jorrit,

Can you try below code:

var url=new Packages.java.net.URL("{!link#url}");

var inputStream=url.openStream();

var br=new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(inputStream));

var stre;

var pw=new Packages.java.io.PrintWriter("D://two.txt");

while((stre=br.readLine())!=null){

pw.println(stre);

}

pw.close();

br.close();

inputStream.close();

Regards,

Shiva

All Replies

Posted by Jorrit on 02-Jun-2016 10:11

Update.

I have the following code:

url=new Packages.java.net.URL("{!file#url}");

var inputStream=url.openStream();

how do i set the file using java.io packages  to directory on the server?

Regards Jorrit

Posted by Shiva Duriseati on 02-Jun-2016 11:39

Hi Jorrit,

Can you try below code:

var url=new Packages.java.net.URL("{!link#url}");

var inputStream=url.openStream();

var br=new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(inputStream));

var stre;

var pw=new Packages.java.io.PrintWriter("D://two.txt");

while((stre=br.readLine())!=null){

pw.println(stre);

}

pw.close();

br.close();

inputStream.close();

Regards,

Shiva

Posted by Jorrit on 03-Jun-2016 08:16

Hi Shiva,

Its working!!! youre the best!

Regards Jorrit

Posted by Jorrit on 13-Jul-2016 09:19

Hi Shiva,

Can you please help me?

sinds 2 days my code isnt working anymore.

var v_url = "{!file#url}";

if(v_url !== ''){

var url=new Packages.java.net.URL(v_url);

on the row var url= i get the following error @ serverside tigger:

Server Returned Http Response Code: 500 For Url: somedomain.com/.../dialogerrorpage.jsp (line #17) in formula:

when i open the url in a browser where i logged in i can see the {!file} when i open the url in a browser with no login i get also the error

regards Jorrit

Posted by Shiva Duriseati on 13-Jul-2016 10:38

Hi Jorrit,

Did you make any changes to the code? If not can you debug the formula using "Debug Formula" available under object script trigger and copy the error message?

Regards,

Shiva

Posted by Jorrit on 13-Jul-2016 15:31

Hi Shiva,

I did not change this trigger.

error message:

Server Returned Http Response Code: 500 For Url: test-apps.profile.nl/.../dialogerrorpage.jsp (line #17) in formula:

regards Jorrit

Posted by Shiva Duriseati on 14-Jul-2016 00:39

Hi Jorrit,

Please create a support ticket we can do a quick screenshare session to debug the problem.

Regards,

Shiva

Posted by Jorrit on 15-Jul-2016 03:20

Hi Shiva,

The problem is view permissions on the object of role Portal Guest!

thats strange because its a serverside trigger i will create a Support ticket to see why the serverside trigger do nat have permissions for that object.

Regards Jorrit

Posted by Shiva Duriseati on 15-Jul-2016 05:41

Hi Jorrit,

As discussed over the call, please make the mark the checkbox in edit field(!file#url) of "file upload" ,since you want the file to be publicly accessible.

Regards,

Shiva

This thread is closed