Controlling the filename of a downloaded file.

From: Ben Jessel (
Date: 11/25/03

Date: 25 Nov 2003 06:55:45 -0800

I have a requirement where files, which are stored in a repository
with names such as 1.jpg, 2.gif, 3.pdf must be presented for download
by the user, but with different filenames from how they are called in
the repository.

The reason being that the internal repository of the system arranges
and stores files by giving them an index number. Their real "name" as
far as the user is concerned is held in a mapping database.

The reason we do this is because:

 a) we may not want the user to directly access the file from within
    repository; my servlet provides the ability to impose security
    and enable an element of control when accessing the file.
 b) It enables us to have files with the same "name" ( as far as the
    concerned ) to be stored without having to resort to some
 c) Filenames which have the same ID as the "objects" to which they
relate to,
    enable easier business logic and archiving implementations.

However, I want the user to be presented with the original filename
when the come to download the file. So if the file was initially
"uploaded" as "myfile.gif", it is stored as, say 1.gif. When a user
downloads it, the link should be something like
/servlets/accessRepository?id=1&repository=articles, and when the file
downloads, the user gets an option to save it as, "myfile.gif".

I can set the mime type of my servlet o.k, and I know how to spool
bytes to an output, but the name of the file seems to always be the
name of the link. Is there anyway to specify what the name of the file
will be?

Relevant Pages

  • Re: Some thoughts about yum and repositories
    ... > can at least use a yum.conf if we can copy or download it. ... that yum can locate and download for you. ... When you want to add a new repository to your yum.conf, ... You can use a tool like wget to download packages ...
  • Re: Offline update
    ... server is isolated and not able to go out on the web to RHN? ... *) Use another host with external access as a RHEL mirror, using "reposync" to mirror the entire download repository channels. ... which has a far more reliable software downlod and repository mirroring capability and has fundamental software compatibility with RHEL. ... The software channels and their associated DRM are one of the most irritating aspects of RHEL: even the recent "yum-rhn-plugin" in RHEL 5 is actually "up2date", wearing granny's nightgown, and ignores basic features of yum such as channel-specific configuration files to provide channel-specific "exclude" ...
  • Re: [opensuse] YAST2 not displaying package descriptions
    ... package descriptions for most of the rpms that came with the DVD. ... local repository. ... time to download when a large repository refreshes. ...
  • Re: Debian 5 - was Re: Query abouut root account
    ... I tried repeatedly, to download DVD1, and Debain 6 can't handle downloading the 4.4GB - whatever I tried to use to download the ISO image, crashed, and required the computer to be physcally turned off - it would get to about 1.2GB, then the system noitorf applet in the panel would disappear, and the display within the window would go blank, and, when booted upa agian, would show less than 100MB stored. ... I had tried to download DVD1, to instal from that, as I had, some time ago got the impression,k that it is likely that most, if not all, of the packages needed for a fairly comprehensive installation, are on DVD1 of an ISO image set, and so that should have been sufficient to be a self-sufficient installation. ... I ended up going back to the 2009 CD1, and using the repository mentioned elsewhere, which, as I showed in another email sent a short time ago, worked. ...
  • Re: Info on options to yumdownloader
    ... kernel source of running kernel. ... The -e option enables a ... download required packages ... enable repository ...