on 03-25-2010 5:04 PM
Does anyone know why this code is giving me to save the file with the wrong filename? It converts spaces to + signs.
Currently it gives the filename: "test+filename.abc"
The variable resourceName is: "test filename.abc" (<-- this is required filename)
IWDResource resource = WDResourceFactory.createResource(baos.toByteArray(),"test filename.abc",WDWebResourceType.UNKNOWN);
String url = resource.getUrl(WDFileDownloadBehaviour.AUTO.ordinal());
String resourceName = resource.getResourceName();
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(url,"download").show();
Edited by: Tom Franssen on Mar 25, 2010 6:04 PM
Tom,
I think you are downloading file by opening a URL, in this case all the blank spaces in URL will be converted in + sign as space is not allowed in URL.
if you don't want to have + sign in your file name you can use download UI element of WebDynpro.
Ninad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
I know exactly what you are looking for.
I have implemented it in my web dynpro application.
Here is the code which you can write in action handler of the download button:-
This will open up a pop-up window asking user to Open/Save As/Cancel type of dialogue.
And you need to perform String manipulation on "p_FileName" to remove all the leading, trailing and intermediate spaces in filename.
try {
//Get Url connection and inputStream
l_url = new URL("<URL STRING>");
l_urlConnection = l_url.openConnection();
l_inputStream = l_url.openStream();
//fill up byte array
int l_int_arraySize = l_urlConnection.getContentLength();
l_byteArray = new byte[l_int_arraySize];
l_dis = new DataInputStream(l_inputStream);
l_dis.readFully(l_byteArray);
//reset buffers
l_inputStream.close();
l_dis.close();
//Set the Resource for file
l_resource = WDResourceFactory.createResource(l_byteArray, p_FileName, WDWebResourceType.UNKNOWN);
l_byteArray = null;
//Get the url of created resource
l_str_url = l_resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());
//Call external window passing the above url
l_win_MultiFileWindow = wdComponentAPI.getWindowManager().createNonModalExternalWindow(l_str_url);
l_win_MultiFileWindow.show();
}
catch (Exception e) {
}
Hope it helps.
Let me know in case you need more information.
With regards,
Amey Mogare
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.