• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FileDownload
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FileDownload


  • Subject: Re: FileDownload
  • From: Serge Froment <email@hidden>
  • Date: Mon, 17 Nov 2003 10:42:24 -0500

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.

  • Prev by Date: Database or Realtime
  • Next by Date: Re: Pb updating a to-many relationship with refaultAllObjects()
  • Previous by thread: RE: FileDownload
  • Next by thread: Re: FileDownload
  • Index(es):
    • Date
    • Thread