Forum OpenACS Q&A: Re: Bboard attachments

Collapse
2: Re: Bboard attachments (response to 1)
Posted by Vadim Makarov on
I don't have a solution, but here are a couple leads.

The browser just takes the text between the last slash sign and the first question sign in the URL, and thinks it is the filename (possibly adding an extension according to the specified MIME encoding). To make sure this text is your filename, you'd need to modify the message display code that produces links to attachments to link to e.g. .../attachment_m/filename?file_id=..., and then make the request processor recognize it and turn it into .../attachment?file_id=... The latter you can probably do via attachment_m.vuh, but I've never done the .vuh stuff and can't explain this part. Can anyone help?

Another possibility is to add a "Content-Disposition" header when the bboard serves the attachment. Find and modify the code that serves the attachment, to include a suitably formed header into the output. I'm afraid, however, this method can lead to incompatibility and strange behaviour in some browsers, e.g. always offering to save the attachment instead of displaying it, wrong file type etc.

I'd prefer the first method that puts the right filename into URL. It works in Netscape 4.7, so it must be trouble-free in all other browsers too :)

Collapse
3: Re: Bboard attachments (response to 2)
Posted by Diego Manilla on
Thanks Vadim, your comments have been very useful. I didn't know the exact behavior of vuh files, but after taking a look at the docs (Virtual URL Handlers section) it has been really easy to do what you suggested (the first option). I only needed to create a subdir in /packages/bboard/www with an index.vuh inside as simple as

ad_page_contract {
	serve bboard attachment
} {
    file_id:integer,notnull
}

ad_returnredirect "../attachment?file_id=$file_id"

... and modify the attachments link to make it appear with the real name of the file.

It works, at least with the couple of files that i've tested sing Mozilla 1.0.

You suggested to create an attachments_m.vuh file, but i read here in the forums that only the index.vuh works (at least in OACS 4.5), although i haven't tested that.

But... there's still one problem: the files with spaces in their file name. A file called "my file.swx" will appear in the save as dialog as "my%20file.swx", and i'm afraid this has no possible solution, hasn't it?

regards