Hello,

to download any file (not just audio), what I do is something along
the following lines (Restlet 2.0snapshot):

Representation getFile() throws Exception {
  File theFileToDownload = retrieveFile(); // This can be a temp file,
a file gotten from the filesystem, from DB, ...
  MediaType mt = getMediaTypeFor(theFileToDownload); // Guess media
type for the file in question
  FileRepresentation rep = new FileRepresentation(theFileToDownload, mt);
  Disposition disp = new Disposition(Disposition.TYPE_ATTACHMENT);
  disp.setFilename(theFileToDownload.getName());
  disp.setSize(theFileToDownload.length());
  rep.setDisposition(disp);
  return rep;
}

Needless to say, you have to implement retrieveFile() and
getMediaTypeFor(File) according to your needs.
You have to also take care of deleting theFileToDownload once it's
been downloaded (there's a discussion about this started by myself not
long ago, I still didn't have the time to investigate the proposed
solutions).

Hope this helps.

On Wed, Mar 3, 2010 at 12:45 AM, Vikash Agrawal <[email protected]> wrote:
> Hi, I have the requirement to provide the feature for downloading of file 
> using Restlet 2.0. As you already have this feature, could you please share 
> this with me or give me some idea on it.
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2454235
>



-- 
Fabián Mandelbaum
IS Engineer

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

Reply via email to