I am using aaa for uploads (Upload model) of assets to a dir below
public. I also need to save files, into the Upload model, which come
as attachments by email. Is there a way I can ask aaa to save the
attachment as if it was uploaded? TIA,
I am using aaa for uploads (Upload model) of assets to a dir below
public. I also need to save files, into the Upload model, which come
as attachments by email. Is there a way I can ask aaa to save the
attachment as if it was uploaded? TIA,
bakki
bakki,
you should be loop through the email’s attachments and create new
Uploads like this:
for attachment in email.attachments
Upload.create! attachment
end
note: this is untested code, but should point you in the right
direction.
Have a look at this article regarding Action Mailer’s attachments:
I was wondering if acts_as_attachment can take an attachment passed to
the model vs. the uploaded file which it normally gets from cgi param.
I thought the validates_as_attachment call back might not work if the
attachment was passed to the model as you suggest. I’ll have to look
the aaa code over to see if this doesn’t work.
yes, that’s it precisely. I guess acts_as_attachment has TestUploadedFile somehow encapsulated, but I couldn’t get it to
work, don’t recall precisely why. I recently used TestUploadedFile
to import loads of legacy data into ported application with great
results.
This actually should work for me. I was looking at the code in
acts_as_attachment and it has the following code which handles
uploaded files.
# This method handles the uploaded file object. If you set the
field name to uploaded_data, you don’t need
# any special code in your controller.
#
# <% form_for :attachment, :html => { :multipart => true } do
|f| -%>
#