Normally RForum attachments don’t have a content type set when RForum
sends the file to the browser, so application/octet-stream is used as a
default and most browsers pop up a “Save as” dialogue. If you would
prefer files to be shown inline (particularly handy for images) then the
following achieves it.
(1) Install mime-types gem: ‘gem install mime-types’
(2) Alter ‘app/controllers/attachment_controller.rb’:
Does the job for me. I’ve not submitted this as a patch / ticket as it
introduces a new external dependency so I don’t expect it to be too
interesting as a general feature addition, but I’m happy to do so if
people on the list think it worthwhile.
Hi Andrew H. :
I do want you write,but after i uploaded a picture(.jpg), i download
the picture,the browser just redirect to a URL some like
“http://localhost/attachment/3/32680.jpg” and the templete is just the
same words. i can’t download the picture.
if we upload the attachment file(e.g demo1.jpg), can we edit the
attachment file to anthoer(e.g demo2.jpg)? it seems i can’t change it.
current version don’t surpport it?
Well spotted; the platform I’m running RForum on doesn’t seem to care
about ‘w’ vs ‘wb’ given that attachments are saved correctly. Yours, on
the other hand, must. Out of interest, what operating system are you
using?
2.if the upload file(test.txt) contain some chinese words ,it seems the
browser can’t decode these words
That’s presumably because the file ‘test.txt’ by itself contains no
indication of the character set in which the text file is encoded. Plain
text files, unlike HTML, have no mechanism for indicating this. I don’t
think this has any connection with RForum. You probably need to manually
set the encoding type (e.g. in Firefox, use the “View -> Character
encoding” menu), set the default encoding type system-wide (the way to
do this depends on your operating system and the browser might ignore it
anyway), or just load the file into a text editor that you know will
display the Chinese words properly.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.