Uso de Paperclip para cargar un archivo desde un trabajo en segundo plano

We're using Paperclip to upload files to S3 by presenting a browse dialog to the user. That's works nice & smooth. However, now I wish that some background job will do some crawling, and when it reaches a required file, upload that one as well. Obviously I can't use the browse dialog at this point.

All examples I saw for using Paperclip is about selecting the file manually from the client (by updating the view). I've failed to find how to set up the file to be uploaded by code, and since the UI component triggers some "behind the scenes" work that creates some object with additional information that I couldn't find how to use or call.

¿Algunas ideas? Gracias

preguntado el 05 de mayo de 13 a las 15:05

1 Respuestas

You can create a Paperclip Upload without using your browse dialog and an user action is also not required. Paperclip needs a file, simple generate a tmp file or use an existing file from your storage.

Your Paperclip model class:

class YourPaperclipmodel < ActiveRecord::Base
  has_attached_file :data

Generate file:

YourPaperclipmodel.create(:data =>"path to existing file or tmp generated file"))

contestado el 05 de mayo de 13 a las 23:05

Already tried to, but it requires Reputation 15, which I don't yet have. - user2339344

Ah ok, didn´t know that :). but now somebody else does it, thanks ;) - Matías

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.