Hi All

I do a PUT with the Restlet GWT client and create a FileRepresentation using
the parameters supplied in the request as follows, unfortunately the "save
as" dialog doesn't appear in Firefox 3.5.7. Firebug response headers seem OK
and the response body contains the file contents. Am I missing something,
like setting the Disposition size ? TIA Andy

public class restlet extends ServerResource {

        @Put
        public void returnFile(String path) {

                Response response = getResponse();
                
                Representation representation = new FileRepresentation(path,
MediaType.TEXT_PLAIN);
                
                Disposition disposition = representation.getDisposition();
                disposition.setType(disposition.TYPE_ATTACHMENT);
                disposition.setFilename("download.txt");
                
                response.setEntity(representation);
        }

}




Fabian Mandelbaum wrote:
> 
> Hello,
> 
> as for the "Save as Dialog", you should do something like this:
> 
> Disposition attachment = new Disposition(Disposition.TYPE_ATTACHMENT);
> attachment.setFilename("the file name here");
> representation.setDisposition(attachment);
> return representation;
> 
> This will set the proper HTTP headers so the browser will popup the
> "save as" dialog when receiving representation.
> 
> On Sat, Oct 9, 2010 at 8:05 AM, Jerome Louvel <[email protected]>
> wrote:
>> Hi Nirav,
>>
>> There is an equivalent property in the Restlet API, see this page for a
>> complete mapping table:
>> http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/324-restlet/130-restlet.html
>>
>> Best regards,
>> Jerome
>> --
>> Restlet ~ Founder and Technical Lead ~ http://www.restlet.org
>> Noelios Technologies ~ http://www.noelios.com
>>
>>
>>
>> -----Message d'origine-----
>> De : [email protected] [mailto:[email protected]]
>> Envoyé : vendredi 8 octobre 2010 16:15
>> À : [email protected]
>> Objet : Content-Disposition
>>
>> Hello All !
>>
>> I have a web service which sends back PDF/CSV files to the browser.
>> But these get downloaded through the browser with a default name and no
>> extension!
>>
>> How do I get the browser to display a 'save as' dialog box and also
>> specify the type of file am sending through (pdf/csv) ?
>>
>> Cheers!
>> Nirav
>>
>> ------------------------------------------------------
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2669320
>>
>> ------------------------------------------------------
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2669583
>>
> 
> 
> 
> -- 
> Fabián Mandelbaum
> IS Engineer
> 
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2669592
> 
> 

-- 
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Content-Disposition-tp5615323p5641619.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2672558

Reply via email to