on 03-17-2009 11:27 AM
Hi Experts,
I am getting File paths from Database like "C:\Invoice\Invoice1.txt"(Client Machine Path).
My Requirement is to get the file from the Path, convert into bytes & pass to RFC to store back end.
How to create IWDResource Object to read file from Client Machine. IWDResource is accepting only file content, but i have only file path.
How to get byte content of the file from client Machine?????
Please any one help me to solve this ?????
Regards,
Satya.
Can you use a file upload UI and provide the client machine path (which you are getting from db) as input to this UI element by coding... i.e by setting appropriate context?
On second thoughts, why would one want to have an additional UI element to upload file to server when it is not used directly by enduser anyway... and it might not even be feasible. However there must be some way to read the file from the local path that you fetch from DB... let me get back in case I find something on this!
Edited by: Anagha Jawalekar on Mar 18, 2009 10:27 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Satya
As I understood
1. U will get filepath from db (so this file path is for client machine or server(it could be local or remote) )
2. U have to take this file parh and lookup for the content (.txt) file right (I assume client machine where app is running )
3. U have to take the content and again give it back to rfc (db).
If this is the case then internally u have to pass the file path (let say some method is there ) which will return some information of file size ,file name ,from here u can proceed .
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satish,
1. I am getting file path from DB (only Client Machine paths based on IP,System Name, OS UserLogin)
2. If(f.exists()) code i will right to check file existence, but this will run on server side right. It will check in server side, but file is available in client side.
3. File Not Exists.
Regards,
Satya.
Hi Satish,
IWDResource resource = wdContext.nodeSales_Orders().getResource();
ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)resource.read(true);
byte bytearr[] = new byte[10000];
byteArrayInputStream.read(bytearr);
I don't have resource object which is pointing to my file path(C:\Invoice\Invoice1.txt). In above code Resource Object is mapped to View UI element, If you select any file from browse option then Resource object is pointing to selected file.
I don't have any UI Element to select File path, directly i have path from DB. In first Step itself not able proceed(Creating Resource Object).
Regards,
Satya.
Hi
I have asked some clear question that where is the resource which u have to process.
Ok let understand from one example : "D:\OLD UAM\Workspace Content\workspace.jdi\0\DCs" this is the path of my system, which contain one pdf which has solution of your problem.Now can u access this pdf from your system, can u convert into bytes & pass to RFC to store back.
U need some physical existences of the resource
So who is the client here ---web browser which runs this application.read this [Doc|; for some more input
Best Regards
Satish Kumar
Hi
First u can check whether file is exists or not, then u can download these content into particular node from here u can pass data to rfc.()
See code for help
IPrivateUserDataView.IUploadFileInformationElement element = wdContext.currentUploadFileInformationElement();
if (element.getFileResource() != null)
{
IWDResource resource = element.getFileResource();
if (resource.getResourceType().getFileExtension().equals("text"))
{
wdContext.currentUploadFileInformationElement().setFileName("File Name : " + resource.getResourceName());
wdContext.currentUploadFileInformationElement().setFileSize("File Size : " + getFileSize(resource));
try
{
// Your Operations
}
}
}
About uses of IWDReso follow previous reply.
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satya,
Please check this code. May be this helps you!!
IPrivatePercompView.IContextElement element = wdContext.currentContextElement();
File file = new File("\\'network\'Shared\'files\file''");
InputStream input;
int temp;
FileOutputStream op = new FileOutputStream(file);
if (element.getFileResource() != null) {
IWDResource resource = element.getFileResource();
input = wdContext.currentContextElement().getFileResource().read(false);
while((input.read())!=-1)
{
temp = input.read();
op.write(temp);
}
op.flush();
op.close();
}
}catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException(e.getMessage(),false);
}
Please let me nkow if this works.
Thanks and Reagrds
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
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.