I use Ruby on Rails, Apache. Faced the problem of uploading a file to the server. I read similar articles here, but it did not help, or my hands are not growing from that place. I use the usual form to send <%= f.file_field :path %> and the controller:

 def upload uploaded_io = params[:article][:path] File.open(Rails.root.join('public','uploads',uploaded_io.original_filename,'wb') do |file| file.write(uploaded_io.read) end end 

There is params.require(:article).permit(:path)

The question is, why do not download files larger than 7kb? It is clear that more than 7-10Kb file is stored as a stream, but how to handle it? When you try to download a file larger than 7kb, the cgi script error 500 is generated, and at sizes up to 7kb, everything is fine. I ask for help in explaining. And where did this 7kb limit come from?


Error log: "An error occured in mod_passenger: An error occured while uploading a temporary file in /tmp/passenger.1.0.965717/generation-163/buffered_uploads. This is a directory that should be written to the "PassengerUploadBufferDir" directive to this directory. Not enough permissions to write to the folder folder passengera.

  • 500th error is usually not caught Exception, find a more specific description in the logs. - D-side
  • From the question it is completely incomprehensible how to make such a conclusion. Edit so that you can leave a reasonable answer? Or close on "not reproduced / typo"? - D-side
  • The error was in the permissions of the buffer folder Passenger. "Error: an error occured while buffering HTTP file uploading to a temporary file in /tmp/passenger.1.0.965717/generation-163/buffered_uploads. This is a writable guideline for the Apache can be written to the "PassengerUploadBufferDir" directive. I specified PassengerUploadBufferDir in .htaccess and it all worked. - Maks
  • Not bad. Add this message to the question and write the answer. - D-side
  • No not like this. In the message, add what was in the logs, and the answer separately. - D-side

1 answer 1

Solution: Change permissions in the standard folder, or point to another folder with the option 'rw'. Edit PassengerUploadBufferDir in .htaccess.