on 05-09-2007 4:28 AM
anyone can help me on this
from the coding , you can see that the getByteArrayFromResourcePath() is get from the local disk drive...
if i save the file in binary format in database , how to i retrieve back the file
pls advice
public void wdDoInit()
{
//@@begin wdDoInit()
IWDAttributeInfo attInfo=wdContext.getNodeInfo().getAttribute(IPrivateDownView.IContextElement.SOURCE);
IWDModifiableBinaryType binaryType=(IWDModifiableBinaryType)attInfo.getModifiableSimpleType();
binaryType.setFileName(DownView.FILE_NAME);
binaryType.setMimeType(WDWebResourceType.XLS);
try{
//String resourcePath=WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),DownView.FILE_NAME);
String resourcePath="C:\tmnet.xls";
wdContext.currentContextElement().setSource(this.getByteArrayFromResourcePath(resourcePath));
//}catch(WDAliasResolvingException e){
//wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(),true);
}catch(Exception e){
throw new WDRuntimeException(e);
}
//@@end
}
//@@begin others
private byte[] getByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int length;
byte[] part = new byte[10 * 1024];
while ((length = in.read(part)) != -1) {
out.write(part, 0, length);
}
in.close();
return out.toByteArray();
}
private static final String FILE_NAME = "tmnet.xls";
//@@end
Message was edited by:
yzme yzme
Hai,
This blog may help to you
/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqlserver-in-webdynpro
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yzme,
This path is on your WAS and not of your local machine (unless you have everything local) and from which database are you talking of saving and retrieving from. Kindly specify.
Regards
Sid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please tell me how to upload file from local machine.
I have successfully uploaded files by using File Upload UI element where I am able to select the required file.
Now I have a requirement of picking up a file from desktop using the code.
If I am simply giving the path "C:
Folder\file.txt", it is searching on server.
Thanks!!
Anubha
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.