Controlling the filename of a downloaded file.

From: Ben Jessel (ben.jessel_at_morpheme.co.uk)
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
the
    repository; my servlet provides the ability to impose security
constraints,
    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
customer's
    concerned ) to be stored without having to resort to some
complicated
    create-some-nested-sub-directory-when-a-file-of-the-same-name-is-
    encountered.
 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 ...
    (Fedora)
  • 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" ...
    (linux.redhat)
  • 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. ...
    (SuSE)
  • Re: Web update library in python?
    ... I want to provide my users the ability to download a repository from ... and after that check for updates. ... and let the patch be applied locally. ...
    (comp.lang.python)
  • Re: Info on options to yumdownloader
    ... kernel source of running kernel. ... The -e option enables a ... download required packages ... enable repository ...
    (Fedora)