on 05-25-2009 7:49 AM
Hi all,
I want to convert context attribute of type IWDResource into byte array. Any idea how to do this conversion?
Pls help.
Thanks and regards,
Amey Mogare
Hi,
This is the code we have used to read the file whild uploading. Hope this helps.
IWDResource resource = element.getCtx_va_FileResource();
InputStream stream = resource.read(true);
String resourceName = resource.getResourceName();
String resourceExtn = resource.getResourceType().getFileExtension();
Here InputStream is - abstract class is the superclass of all classes representing an input stream of bytes.
Regars,
Charan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for reply.
I just tried read method of InputStream and it worked..
Following is the code which I used to convert Resource to Byte Array
InputStream l_is_FileStream = wdContext.currentContextElement().getUploadedFile().read(false);
int l_int_NoOfBytes = l_is_FileStream.available();
byte[] byteArray = new byte[l_int_NoOfBytes];
int l_int_byteRead = l_is_FileStream.read(byteArray, 0, l_int_NoOfBytes);
This code populates byteArray[] with data of Resource.
Thanks and regards,
Amey Mogare
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.