Hi Fabian,

With Restlet 2.0 M7 and using the internal HTTP connector, you can register an 
"onSent" callback on the response. See ServerResource#setOnSent(Uniform) method.

Also, I have just checked in SVN trunk a change that makes this callback work 
with other HTTP connectors. That should help you.

Otherwise, if you want a more general cleanup strategy, you could customize 
your application's connectorService property, overriding the 
afterSend(Representation) method.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.org
Noelios Technologies ~ http://www.noelios.com




-----Message d'origine-----
De : Fabian Mandelbaum [mailto:[email protected]] 
Envoyé : lundi 8 février 2010 14:31
À : [email protected]
Objet : Delete temp file automatically after it's been downloaded

Hello there,

some of my resources provide a FileRepresentation with a file to
download, like this:

File file = createTempFile();
Representation rep = new FileRepresentation(file, mt);
Disposition disposition = new Disposition(Disposition.TYPE_ATTACHMENT);
disposition.setFilename(file.getName());
disposition.setSize(file.length());
rep.setDisposition(disposition);

I was wondering if there's a way to say to Restlet to automatically
delete the file once it has been streamed back to the client (that is,
once the client finishes downloading it). Using Restlet 2.0M7.

Thanks in advance for your answers

-- 
Fabián Mandelbaum
IS Engineer

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

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

Reply via email to