Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FileDownload



Hi Kranthi,

Here is the code I use in a direct action to trigger file downloading.
This works with Safari and IE on both Mac and Windows machines. The
file is downloaded with the file name I pass in the Content-Disposition
header.

	public WOResponse downloadAction()
	{
		String desktopRequest = (String) request().formValueForKey("id");
		Desktop desktop = Application.desktopWithID(new
Integer(desktopRequest));
		desktop.photo().incrementDownloadCount();
		WOResponse response = new WOResponse();
		response.setHeader("data/binary", "Content-Type");
		response.setHeader("attachment;filename=" + desktop.filename(),
"Content-Disposition");
		response.setContent(desktop.desktopImage().image());
         return response;
	}

Le 16 nov. 2003, ` 10:01, Kranthi Sagar Borra a icrit :

> I used "application/octet-stream" as the MIME type.But this downloads
> the file with a different name every time like 12345.jpg instead of
> hello.jpg.Can somebody please tell me how I can resolve this
> issue..Thank you.
>

Serge Froment
http://www.serge-froment.com
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.