RE: FileDownload
RE: FileDownload
- Subject: RE: FileDownload
- From: "Kranthi Sagar Borra" <email@hidden>
- Date: Sun, 16 Nov 2003 19:56:47 +0530
- Thread-topic: FileDownload
<<Picture 2.pdf>>
Hi Richard.
I have tried that one too.But now its displaying me a page as show in the
attachment.
Regards,
Kranthi Sagar
> ----------
> From: Richard Bruch
> Sent: Sunday, November 16, 2003 5:02 PM
> To: Kranthi Sagar Borra
> Subject: Re: FileDownload
>
> Hi Kranthi,
>
> i'm not sure but i think, the problem is with the mime type. You set it to
> text/html so the browser feels responsible for interpreting the contents as
it
> does with any other html page(they all have the text/html type). Should
your
> file be a text/html file try to set the mime type to text/plain for
example,
> otherwise to whatever appropriate. If the browser thinks it is not able to
> handle the contents it will offer you to store it locally.
>
> Regards,
>
> Richard
>
>
> ----- Original Message -----
> From: "Kranthi Sagar Borra" <email@hidden>
> To: "Richard Bruch" <email@hidden>
> Sent: Sunday, November 16, 2003 12:21 PM
> Subject: RE: FileDownload
>
>
> <<Picture 1.pdf>>
> Hi Richard,
>
> Thanks a lot for the help.I think that is what I should do but I still have
few
> queries.This is what I have done.
>
> public void appendToResponse(WOResponse aResponse, WOContext aContext) {
> super.appendToResponse(aResponse,aContext);
>
>
> aResponse.setContent(data);
> aResponse.setHeader("text/html;
charset=UTF-8;","content-type");
> if (fileName != null){
> aResponse.setHeader("attachment;filename=\"" +
> fileName + "\"",
> "content-disposition");
>
>
> }
> }
>
> and above this I have defined data as "NSData data=new
> NSData(downloadedFile);".where downloadedFile is the file on the server ,
that
> should be downloaded.
>
> But when I click on the file that is to be downloaded.The response is
created
> and I am going into a new page where the raw data is getting shown.Picture
1.pdf
> shows what I am seeing.But this is not what I want.I wanted to downlod the
file
> on my desktop.So can you please tell me what I can do.Thank you.
>
> Regards,
>
> Kranthi Sagar
> Extn:6799
> Direct:0824-2226799
> Cell:9845791246
>
>
>
> > ----------
> > From: Richard Bruch
> > Sent: Sunday, November 16, 2003 1:39 AM
> > To: Kranthi Sagar Borra
> > Cc: email@hidden
> > Subject: FileDownload
> >
> > Hello Kranthi,
> >
> > supposed you have an object "data" with data loaded from the desired
server
> file
> > you can build a WOResponse object and return it as result of a given
direct
> > action.
> >
> > r.setHeader(data.getMimetype(),"content-type");
> > r.setHeader("attachment;
> > filename=\""+data.getFilename()+"\"","content-disposition");
> > if(data.stringData != null) // data is in a string
> > r.appendContentString(data.stringData.toString());
> > else // data is in an NSData instance
> > r.appendContentData(data.getRawData());
> >
> > Regards,
> >
> > Richard
[demime 0.98b removed an attachment of type application/octet-stream which had a name of Picture 2.pdf]
_______________________________________________
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.