Problems downloading large text files through Paperclip

I am upgrading from Ruby 1.8.7 to 1.9.3 and from Rails 2.3 to 3.2. As part of this update, I am moving from Paperclip 2.2.9 to 3.5.2. My version of ImageMagick is 6.8.6. One of the problems that I discovered as part of the upgrade process is that download performance is very poor when it comes to large text files (~ 1 MB). These files do not have to be .txt files, also in any text format (.xml files).

For your reference, here is my installation of Paperclip:

  has_attached_file :attachment,
    :url => "/shared_documents/:id/:basename.:extension",
    :path => ":rails_root/user_uploaded_content/shared_documents/:id/:basename.:extension"

For simplicity, I omit our checks, etc., since we just check the file size and availability.

Watching the running processes on my development machine, it seems that a bottleneck occurs when Paperclip calls the ImageMagick command identify. Calling identifyin various files via the command line allowed me to verify that metadata is returned almost immediately for image files, but large text files without an image take a lot of time to process.

For my application, I allow users to upload documents in any format they like, so I should be able to efficiently process both images and text files. Has anyone else encountered this problem? Is there a way to selectively disable the call identifyin certain file formats in a folder, but not in others? Otherwise, we could live without simply calling identifyif this is an option. Perhaps there is a way to install configure ImageMagick for more graceful processing of large text files?

+4
source share
1 answer

, Paperclip, . Paperclip . - :

has_attached_file :attachment, 
  styles:{}, 
  url: "/shared_documents/:id/:basename.:extension",
  path: ":rails_root/user_uploaded_content/shared_documents/:id/:basename.:extension"

has_attached_file :attachment, 
  processors:[], 
  url: "/shared_documents/:id/:basename.:extension",
  path: ":rails_root/user_uploaded_content/shared_documents/:id/:basename.:extension"

before_post_process false, , Paperclip identify , :

has_attached_file :attachment, 
  url: "/shared_documents/:id/:basename.:extension",
  path: ":rails_root/user_uploaded_content/shared_documents/:id/:basename.:extension"

before_post_process :skip_processing

def skip_processing
  false
end
+2

Source: https://habr.com/ru/post/1523949/


All Articles