Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Copying file to '/usr/local/neolane/nl6/var/<instance_name>/<file_name.extension>'

Avatar

Level 2

Hi,

I've been trying to copy a file from outbound of FTP and copy to 'Public File Resources' in Adobe Campaign Classic. And I was able to copy the file using the following command.

var serverFileResourceLocation = "/usr/local/neolane/nl6/var/<instance_name>/<file_name.extension>";  

if (!file.copyTo(serverFileResourceLocation)) 

     logError ("File '" + file.name + "' was not copied"); 

else

     logInfo('copied successfully');

The same was working in Sandbox instance. And in another instance that fails and gives the follwing error.

Error: "BAS-010015 Cannot open file '/usr/local/neolane/nl6/var/res/stage1/896058c047415b9ec73256866fa2e447.pdf' with write access (errno=2, No such file or directory)"

I've tried giving Read/Write/Delete permission to the operators for 'Public Resources folder' and still it didn't resolve the issue.

I've used the following forums for my references:

I want to Upload images to Public resources every morning. Is it possible to automate this process.

Re: Automate Report Sending

I've spent some days to resolve this and still no fruit. Any help will be much appreciated. Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello somasundaramh14124455​,

the thing is the sandbox is all in one and in production environment  you would have multiple resource servers that can be installed on different physical servers across the network. So you need to publish those files either by using method PublishIfNeeded after you saved the file locally and to database or manually upload everything to each server respectively.

fileRes.PublishIfNeeded ();

PS:

Check JSAPI for fileRes

BR,

Marcel

View solution in original post

9 Replies

Avatar

Community Advisor

Hi somasundaramh14124455​,

I can see the paths are different in your code and error. "res" is missing.

Regards,

Deb

Avatar

Level 2

Hi Debabrata.T,

Let me clear this. That 'res' stands for public file resources directory(I just got this info from some forum - so anyone can correct me if i'm wrong).

So even if I have 'res' that works in one instance and doesn't work in another instance. I tested the following and getting same result.

var serverFileResourceLocation = "/usr/local/neolane/nl6/var/res/<instance_name>/<file_name.extension>";  

if (!file.copyTo(serverFileResourceLocation)) 

     logError ("File '" + file.name + "' was not copied"); 

else

     logInfo('copied successfully');

I see that I'm not able to copy a new file into that directory:

I'm unable to write my_file.pdf into 'res/my_instance_name' directory "/usr/local/neolane/nl6/var/res/my_instance_name/my_file.pdf".

Hope this helps to give me a solution.

Avatar

Community Advisor

Hi ,

Yes "res" stands for public resources.

You can try to replace "/" with "//" in you code.

If it still doesn't help I hope it has something to do wit the path.

Regards,

Deb

Avatar

Level 2

Debabrata.T, I tried to escape special characters using the following options. Still didn't help.

  • //usr//local//neolane//nl6//var//res//my_instance_name//my_file.pdf
  • \/usr\/local\/neolane\/nl6\/var\/res\/my\_instance\_name\/my_file.pdf
  • \\usr\\local\\neolane\\nl6\\var\\res\\my\_instance\_name\\my_file.pdf
  • escape('/usr/local/neolane/nl6/var/res/my_instance_name/my_file.pdf')

I wonder the issue is with write access.

Error: "BAS-010015 Cannot open file 'file_path' with write access (errno=2, No such file or directory)"

I confirmed the server path is: "/usr/local/neolane/nl6/var/res/stage1/" using querydef. So the issue is with the write access only I guess.

Avatar

Community Advisor

Hi somasundaramh14124455,

Please find the sample code where I am trying to cope a file and paste it with another name. It is working fine for me. Please double check the path and if it is correct you can reach out to Adobe support.

Code Snippet

var file = new File("/usr/local/neolane/nl6/var/res/instance_name/mypic.png"); 

if(!file.exists)

     logError ("File '" + file.fullName + "' does not exists.");

else

     logInfo("File '" + file.fullName + "' exists.");

if (!file.copyTo("/usr/local/neolane/nl6/var/res/instance_name/halloween.png")) 

     logError ("File '" + file.fullName + "' was not copied.");

else

     logInfo("File '" + file.fullName + "' was copied.");

var copiedfile = new File("/usr/local/neolane/nl6/var/res/instance_name/halloween.png");

if(!copiedfile.exists)

     logError ("File '" + copiedfile.fullName + "' does not exists.");

else

     logInfo("File '" + copiedfile.fullName + "' exists.");

Log

File '/usr/local/neolane/nl6/var/res/instance_name/mypic.png' exists.

File '/usr/local/neolane/nl6/var/res/instance_name/mypic.png' was copied.

File '/usr/local/neolane/nl6/var/res/instance_name/halloween.png' exists.

Workflow finished

Regards,

Deb

Avatar

Level 2

I still get the same error. I can confirm the path using the querdef method which is described in fileRes dataschema. The following gives the path of a file which has the id/primary-key as 4216 in the file resource directory.

var query = xtk.queryDef.create(

  {queryDef: {schema: "xtk:fileRes", operation: "get",

    select: {

      node: [{expr: "@fileName"}]

    },

    where: {

      condition: {expr: "@id = 4216"}

    }

  }})

var fileRes = xtk.fileRes.create(query.ExecuteQuery())

logInfo(fileRes.fileName);

Avatar

Community Advisor

Hi somasundaramh14124455,

This is interesting. May be access issue.

Vipul Raghav

Adhiyan

Please can you help.

Regards,

Deb

Avatar

Correct answer by
Community Advisor

Hello somasundaramh14124455​,

the thing is the sandbox is all in one and in production environment  you would have multiple resource servers that can be installed on different physical servers across the network. So you need to publish those files either by using method PublishIfNeeded after you saved the file locally and to database or manually upload everything to each server respectively.

fileRes.PublishIfNeeded ();

PS:

Check JSAPI for fileRes

BR,

Marcel