Reputation: 6121
I'm working on an app that will let users submit zip files that are about ~5mb in size I imagine. I will then take these files manually and work with them on my end.
I'm looking into using Paperclip as heroku suggests for this task - bypassing heroku entirely - and just uploading to Amazon S3.
However now that I'm messing with it it looks like a user model can have ONE attachment, rather than multiple. Is there a better alternative or perhaps a direct way to just upload to S3 knowing my bucket name and keys and such?
Or is there a way to configure paperclip such that a user can have many attachments? I'm a bit confused what I'm doing.
Upvotes: 1
Views: 747
Reputation: 1767
S3 Post API can be used but this is going to reveal your secret key in forms which is quite vulnerable from security perspective.
you should use direct uploaderm to s3 js library so your secret key remains secret.
Thanks
Upvotes: 0
Reputation: 12273
On popular alternative to paperclip is CarrierWave. When I was looking into file attachments a few months ago it was highly recommended.
Upvotes: 0
Reputation: 3336
Paperclip supports an unlimited number of attachments.
Look into the S3 POST API, which will require some signature paramaters generated on your server, but will allow you to upload directly to S3. After a successful upload to S3, you have to make a separate request to notify your heroku server that there is a new attachment and of the attachment filename. Generally this requires hacking the [attachment]_file_name parameter in order to avoid paperclip unnecessarily uploading the file a second time.
Overall I find Paperclip to have some serious design flaws which means it requires unfortunate hacking in order to play nicely with files that are not uploaded through the plugin. I've had to pretty much hack the thing completely. For my next project I'll look for an alternative that more cleanly separates attachements from models and has a more modular storage mechanism.
That said, the solution I mentioned works nicely. The tricky part is to explicitly set the [attachment]_file_name field on the model so that Paperclip will think the file has original file has already been stored.
Upvotes: 1
Reputation: 10412
You can find many available tutorials to setup paperclip working with multiple attachments.
Upvotes: 3