cancel
Showing results for 
Search instead for 
Did you mean: 

How to use IWDFileUpload to load xml in byte array

Former Member
0 Kudos

In IDE V7.0, how do we get the byte array of the xml file from the local file upload. In old Web Dynpro version, one defines binary and filename in the context node and binds them to data and file name in the control property, then the xml can be uploaded from local xml. However, in 7.0, a new property as "resource" is introduced to replace data and filename properties. I could not find sample code about how to read the local xml file into byte array. Please help. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Tom,

Create attribute with DDIC type com.sap.ide.webdynpro.uielementdefinitions.Resource (at-run-time you may access it as com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource).

Bind "resource" property of file upload / download control to this attribute.

You may manipulate just this attribute to get / set content, mime type and file name.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

I did all of that but where I can find the get content method. I could not find it in the resource object. Do you have sample code. Thanks.

Former Member
0 Kudos

You can get InutStream and read all necessary bytes from there:


final IWDResource resource = element.getMyResAttr();
final InputStream is = resource.read(true);
try
{
/* read bytes from stream */
}
finally
{
  try { is.close(); } catch (final IOException ex) {}
}

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Thanks for the answer but it is not really what is in my mind. In this approach, we need to implement input stream reader, if the xml file is too big, we also need to implement multiple block read. In old version, all this reader were implemented in the IWDFileUpload control. After we bind the binary array to "data" property, the content was automatically loaded. Two questions here:

1) Does the new version provide a similar feature as in the old version. If yes, then what are the methods to access the byte array content.

2) If not, do you have comment on the reason to change backward.

Thanks. Tom.

Former Member
0 Kudos

Tom,

AFAIK 7.0 still supports "data" UI element property, binary data type and all the rest that were previously available (in 6.40). So you may still use that stuff (sure, with bulk of deprecation warnings).

<i>In this approach, we need to implement input stream reader, if the xml file is too big, we also need to implement multiple block read. In old version, all this reader were implemented in the IWDFileUpload control</i>

Sure, this is the reason IWDResource was developed for: instead of pre-loading all binary content in memory, IWDResource allows to store them in disk cache (or whatever, prbably DB) and access them only on-demand. So memory consumption is lesser.

Also I see no problems using SAXSource for xml /xslt processing over InputStream, I can forward you to post here on SDN describing how to read all content from InputStream to byte array.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hai,

Now i am working in webdynpro 2.0.9. It doesn't contain com.sap.tc.webdynpro.services.sal.datatransport.api.so there is no availability to use "resource" to download and upload file. If any possibility to download and upload file other than using this API.

Thanks is advance.

Kindly Regards,

s.v.selva Bala.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hai,

I have the same problem, which is you menstioned. I want to upload one Doc/Image file into server. My version is 2.0.9. Please tell me how to upload one file from client machine into server. I tried "IWDResource", but i coludn't resolve it. If you know please help me.

Thanks in Advance,

Saravanan.