on 07-02-2015 4:47 AM
Hello All,
I need to read a file kept in Portal WRR as inputstream.
From below link, I could write code to get instance of IResource and it's URI, but I don't see any 'getContent' or similar method for this object which will give me inputstream for this file.
Accessing the Web Resource Repository - Portal - SAP Library
Hence, first question is, "Is there any method or standard way to read a WRR Resource as inputstream like we have in KM Resource?"
Then I tried to get inputstream using URI of this object using traditional old URLConnection way.
Hence, I noticed strange thing: -
1. When I try to get inputstream from URL of below pattern, I am able to get the inputstream: -
http : // <host> : <port> / com.sap.portal.resourcerepository / repo / folder1 / Test_Data.csv
2. And when I try to get inputStream using masked hostname URL (the one which actually used by end-users), I get connection timed out error in URLConnection: -
http : // <masked-hostname> / com.sap.portal.resourcerepository / repo / folder1 / Test_Data.csv
Any ideas/pointers?
Thanks & Regards,
Amey
Hi,
Do you have proxy configured?
Remember that when reading a file in sever side, the server itself access the file, whereas when users access it, it may go through reverse proxy ,web dispatcher, etc.
Best Regards,
Tal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amey,
Can you try reading the file with relative URL, not including the host?
/ com.sap.portal.resourcerepository / repo / folder1 / Test_Data.csv
Another try is after you get the resource with code:
IResource resource = resourceRepository.getResource(resourcePath, IResource.CSSfalse)Get its path by: IResourceInformation resourceInfo = resource.getResourceInformation(); File file = new File(resourceInfo.getSource());
Best Regards,
Tal
Thanks a lot, Tal.
It solved with below approach: -
IResource resource = resourceRepository.getResource(resourcePath, IResource.CSSfalse)IResourceInformation resourceInfo = resource.getResourceInformation()File file = new File(resourceInfo.getSource())
Hi Amey,
Can you try using IResource instead of URI?
You can then get the input stream of IResource by the following way:
IResource res
//logic of fetching the resource from WRR is mentioned in the blog mentioned in your question.
IContent content = res.getContent(); //this will return the content of the resource.
InputStream is = content.getInputStream(); // this will return input stream of the resource content.
For more details you can refer to the following documentation:
Best Regards,
Rohit Singhal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Rohit,
Thanks for reply.
However, you are confusing between IResource of KM and IResource of WRR:
Below is IResource of KM, where we get inputStream from getContent method. This is already known to me but it is not what this question is about.
And below is the IResource, which is of WRR, where we dont have any method to retrieve data using any standard method.
Hence, I am using traditional URLConnection way to connect to URL of file and then read the data.
And at this point of time, I am facing issue described in my question above.
I hope this is clear to you.
Thanks & Regards,
Amey
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.