cancel
Showing results for 
Search instead for 
Did you mean: 

Set Values To IWDResource

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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

former_member185086
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

former_member185086
Active Contributor
0 Kudos

Humm............

Ok , My simple question where is that content which u have to process or in simple and in your words

where is that resource exists which u have to convert into byte[].

if It is in client than see this [thread |;

for conversion of IWDResource into Byte[]

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish,

IWDResource resource = wdContext.nodeSales_Orders().getResource();

ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)resource.read(true);

byte bytearr[] = new byte[10000];

byteArrayInputStream.read(bytearr);

Regards,

Satya.

Former Member
0 Kudos

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.

former_member185086
Active Contributor
0 Kudos

Hi

here u have to provide the file path

//Taking file path from rfc and pass it to here 
File file = new File("C:\Invoice\Invoice1.txt''");

Note : Even for Upload element first we have to give the path then further it process the data.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish,

//Taking file path from rfc and pass it to here

File file = new File("C:\Invoice\Invoice1.txt''");

if(f.exists()){

}

This code will run in server side, I won't check in client machine.(but we have client path).

Regards,

Satya.

former_member185086
Active Contributor
0 Kudos

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

Former Member
0 Kudos

The thread is about reading file from server.

former_member185086
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Satish Kumar,

If i write code to check file existence it will check in server, not in client machine...

My problem how to create IWDresoruce from Path???? Without Resource i can't get byte content..

Regards,

Satya.

pravesh_verma
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Pravesh,

Very thanks for quick reply.

File Path which i am getting from back end table is not network path(Example C:\Invoice\Invoice1.txt). These folder are not shared to access.

How to do???? Is there any way to solve this problem??

Regards,

Satya.

pravesh_verma
Active Contributor
0 Kudos

Hi Satya,

Please follow this link which has exactly same issue as yours. I am sure this will solve your issue.

I hope this helps...

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Pravesh,

I don't have byte[] content, I have only file path.

I am not able to create IWDResource with file path.

What u given in that Link From Byte[] to IWDResource creation.

Regards,

Satya.