on 09-01-2006 12:07 PM
Hi,
I tried the tutorial on File Download and am able to download the file sap.jpg.
How can i change and point it to a folder path on my server wherein all images are stored.
Will it pick by default from src->mimes->components->.?
Please let me know.
Secondly, in File Upload tutorial there is no place where we have specified path or folder on the server where images will be stored? How can we put the path where we want to upload images on the server?
Regds,
Dev
Hi,
Yes u can get the file from any server path location.
Use this code in any action event handler by creating the button instead of link.
try {
final byte[] content = this.getByteArrayFromResourcePath("
<server name>
<folder name>
File name.pdf");
final IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.UNKNOWN);
try {
final IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getAbsoluteURL(), "WD_Filedownload", false);
//wdComponentAPI.getMessageManager().reportSuccess("resourcePath"+resource.getAbsoluteURL());
window.open();
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
}
// } catch (WDAliasResolvingException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Declare this method globally:
//@@begin others
private byte[] getByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len;
byte[] part = new byte[10 * 1024];
while ((len = in.read(part)) != -1) {
out.write(part, 0, len);
}
in.close();
return out.toByteArray();
}
//@@end
Similarly for upload in to server path also do the same
IWDAttributeInfo attInfo =
wdContext.getNodeInfo().getAttribute("upload");
binaryType =
(IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
uploadedName = binaryType.getFileName();
File filename =new File("
<server name>
<folder name>
"+uploadedName ); );
try {
FileOutputStream out = new FileOutputStream(filename);
out.write(b);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Regards,
Vijayakhanna Raman
Message was edited by: Vijayakhanna Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
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.