Question

Reading file from external shared location

I am trying to read file from a shared location. The filepath is a UNC- "\\server\folder\file.xml".

I need to read this in java code.

Our Pega server is installed on linux. So I converted the \ to /.

When I use the PRFile api, and provide filepath as "file://server/folder/file.xml", file.exists() returns false and

file.getAbsolutePath() returns "file://default:/server/folder/file.xml".

Passing fileName without "file://" returns the same thing.

So I tried java.io.File. to this I passed URI(filePath) but I am still getting the same results, absoluteFilePath is /server/folder/file.xml and .exists() returns false.

I can access the files in eclipse on my windows machine with java File class.

Can anyone help with this?

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
December 28, 2017 - 2:21am

This is fixed by mounting the external network location on server. We can set path to a folder on server which points to external location and we can read files.

Comments

Keep up to date on this post and subscribe to comments

December 1, 2017 - 1:24am

Please pass path as"file://server//folder//file.xml"

December 1, 2017 - 1:45am
Response to Narasimha522

Hi Narasimha,

I tried what you suggested but that does not do solve the problem.

If I print the absoluteFilePath from PRFile object after passing the path as suggested by you, the path returned is 

"file://default:/Server/folder/file.xml "

If I try the same with java.io.File object, the abosoluteFilePath is 

"/websphere/app/file:/server/folder/file.xml"

If I pass URI to java.io.File object, absolutefilepath is,

"/server/folder/file.xml "

In all these cases file.exists() returns false. But I can access the path and file from windows explorer/browser and local java code.

 

Thanks.

 

 

 

December 1, 2017 - 6:57am

Hi,

Please check the case sensitive of directory and file names, i hope this will help you. Pass the values as it is.

December 3, 2017 - 11:28pm
Response to SudhakarReddy

Hi Sudhakar, I did check the case sensitivity, but that is not the issue. I think we found a solution. I will update this post once we get it working properly.

Thanks anyway.

December 28, 2017 - 2:21am

This is fixed by mounting the external network location on server. We can set path to a folder on server which points to external location and we can read files.