cancel
Showing results for 
Search instead for 
Did you mean: 

Filename with space problem

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

But currently above code is being executed when you click on a button. If I use the download ui element, I get an extra "link", and I need to click on it. So two clicks in total, but only one is required.

Or can I trigger the download automatically?

p330068
Active Contributor
0 Kudos

Hi Tom,

Please remove the space between filename or use _ betwen them and try again.

Hope it helps

Regards

Arun

Former Member
0 Kudos

This is not a sollution, but a workaround.

It should be possible to do it, does anyone have an example? I tried using the download file, binding to the resource, but it still gives me a + sign.

Former Member
0 Kudos

Tom,

It is giving you the + sign because spaces are not possible in URL's. You are downloading from a URL so the + sign is automatically added. I don't think that there is a solution for your problem.

kind regards,

Ted

Amey-Mogare
Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks Amey, but I still need filenames with a space. If p_FileName = "test tom.txt" it will be downloaded as "test+tom.txt".

I also tried replacing all spaces with %20, but then I get %20 in the filename instead of a space.

Former Member
0 Kudos

Tom,

Why do you have the requirement to have a space in the filename? Maybe we can help you fix your problem another way?

kind regards,

Ted