cancel
Showing results for 
Search instead for 
Did you mean: 

FileUpload and RFC problem

Former Member
0 Kudos

Hy guys!

Please, help me!

Where is the problem or error in this code:

IWDResource fileUploadUI;
InputStream fileStream;
byte[] byteArray = null;

for (int n = 0; n < wdContext.nodeFileUploadNode().size(); n++) {

  fileUploadUI = wdContext.nodeFileUploadNode().getFileUploadNodeElementAt(n).getFileUploadAttr();

  try {

    fileStream = fileUploadUI.read(false);
    *int noOfBytes = fileStream.available();*    ERROR
    byteArray = new byte[noOfBytes];
    *int byteRead = fileStream.read(byteArray, 0, noOfBytes);*   ERROR

  } catch (IOException e) {
    e.printStackTrace();
  }

  wdContext.currentCreateAttachRFCElement().setMessage_Key(wdContext.currentContextElement().getServiceRequestID());
  wdContext.currentCreateAttachRFCElement().setAtt_Name(fileUploadUI.getResourceName());
  wdContext.currentCreateAttachRFCElement().setAtt_Bin(byteArray);

  executeCreateAttachRFC();

}

Thanks!

Kleber

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kleber,

Please check this [javadoc|http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#available()]. It will explain why you get an error.

Hope this helps.

regards,

Alain

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi guys,

It works fine:

IWDResource fileUploadUI;
InputStream fileStream;
byte[] byteArray = null;
byte[] byteArrayOrig = null;

for (int n = 0; n < wdContext.nodeFileUploadNode().size(); n++) {

	fileUploadUI = wdContext.nodeFileUploadNode().getFileUploadNodeElementAt(n).getFileUploadAttr();

	try {

		if (n < wdContext.nodeAtts().size()) {
			byteArrayOrig = wdContext.nodeAtts().getAttsElementAt(n).getAtt_Bin();
		}

		fileStream = fileUploadUI.read(false);
		byteArray = new byte[fileStream.available()];
		int byteRead = fileStream.read(byteArray, 0, fileStream.available());

		if (Arrays.equals(byteArrayOrig,byteArray)) {
			continue;
		}

	} catch (IOException e) {
		e.printStackTrace();
	}

	wdContext.currentCreateAttachRFCElement().setMessage_Key(wdContext.currentContextElement().getServiceRequestID());
	wdContext.currentCreateAttachRFCElement().setAtt_Name(fileUploadUI.getResourceName());
	wdContext.currentCreateAttachRFCElement().setAtt_Bin(byteArray);

	executeCreateAttachRFC();
}

Thanks!

Kleber

Former Member
0 Kudos

copy&paste your Stack Trace or compilation errors