views:

155

answers:

1

Hello,

Is it possible to move the (/tmp/stream*) tempfiles generated by paperclip to another location like /railsapp/public/tmp without changing tmpfiles for the whole app enviroment? I would like to show a preview of the uploaded file if valdation fails on the model.

Best regards. Asbjørn Morell

+1  A: 

That's not Paperclip setting. It just uses file web server got from user.

You need to set this on web server level. If you are using Apache and Passenger you most likely want this setting:

http://www.modrails.com/documentation/Users%20guide.html#_passengertempdir_lt_directory_gt

Slobodan Kovacevic
I am using nginx and thin.. hmmm I don't want to expose the entire temp dir to the world. Guess I could hardlink the paperclip tmp files to a dir in the public folder. (before_save) It's a bit strange that this can't be changed for paperclip with an option or parameter. :/
atmorell
atmorell, files in tmp dir are, as the name says :), temporary. Web server gets them from user and puts them in tmp, where Rails/Paperclip can get them. Once you get them they should be moved somewhere - and Paperclip does this automatically.As Vlad pointed out: Paperclip does not create /tmp/stream* files.Not quite sure anymore what exactly you want to do and why.
Slobodan Kovacevic
Let's say a user submits a form and the validation fails. The form is preloaded with the data from the post form. The input/file field however is empty. What I am trying to do is give the user a preview of the file uploaded. The reason I was asking about moving the paperclip tmp files, is because I don't know if there is anything in the rais tmp dir that could be a security risk if moving the rails tmp dir to app/public/tmp
atmorell
You would have to move file manually then. You cannot leave it in tmp dir because it might be already deleted when user makes a next request.
Slobodan Kovacevic
I got it working by linking the /tmp/stream* files to /public/tmp /filename from my controller. link is deleted when the model is saved/file changed.
atmorell