on 10-23-2007 1:49 PM
Hi,
I have a jpg image which is stored in the local system(not on the server).I have written an application from which I am not able to download the image from the local system.
I am using the following code but this code works only if the image is present on the server.
String file = "C:\Folder_Name\image.jpg";
final byte[] content = this.getByteArrayFromResourcePath(file);
final IWDCachedWebResource resource = WDWebResource.getWebResource(content, WDWebResourceType.UNKNOWN);
try
{
final IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(resource.getURL(), "WD_Filedownload", true);
window.open();
}
catch(Exception e) {
wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(e), false);
}
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();
}
And for downloading the file or image from local system I need to put the file in \src\mimes\Components folder; Where as I want the file to be downloadable anywhere from the local file system. Is that possible?
Thanks
Pravin
HI,
I am not able to get wat exactly you mean to say download from local system.
If you have image in local system, then you can upload the image in the server using file upload UI Element. And then you can use it.
For downloading the image to the local system use file download UI Element.
For further details please revert.
Thanks
Anish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pravin,
If you want to display an image existing elsewhere on the local machine, you need to upload it first (use FileUpload UI component), store it in a byte array and then continue with your code below of creating a cached web resource.
And you place resources in src/mimes/component so that they will be available to the application (meaning for all users). This doesnt mean you are displaying the image from the local file system. When you deploy, these images go and live in the server and accessed from there.
In any case, the hardcoded image location in your code is valid only for YOU but not necessarily other user running the same application.
As such, you cannot access the client's file system explicitly (i.e local machine) due to security reasons. I know of no other way to do it with WebDynpro. Any resources must be present on the server side at some point of time. Either at application start or ask the user to provide it (like FileUpload).
No web technology allows that other than signed applets or trusted activex controls, as far as i know.
Hope that clears the confusion.
Thanks,
Rajit
Message was edited by:
Rajit Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use file upload/download component ....
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.