Uploaded timestamp with Carrierwave - ruby-on-rails

I have a model containing several PDFs that are stored on S3 using Carrierwave, and would like to display the uploaded_at timestamp of these files in a view.
I don't see any way to accomplish this built into Carrierwave. Right now I plan to add an uploaded_timestamp field to the model, but am looking for a more elegant way to accomplish this.
Suggestions welcome.

Related

Rails + aws-sk + S3 Object metadata multiple update

I'm currently trying to work out the best way to update multiple S3 Objects MetaData within a single form.
Has anyone done this before or have any suggestions on how I could accomplish this?
I upload the files manually but wish to update some metadata i add when I upload manually. e.g. x-amz-meta-friendly-title, x-amz-meta-description, x-amz-meta-active
Any guidance is much appreciated.

configure paperclip to generate styles when they are requested

I need a user to upload an original file and process that into a thumbnail (paperclip's got this - check).
Then I would like to be able to retrieve different styles for that attachment, but I do not need to store those different styles on disk anywhere. I would prefer they are generated during the request.
The reason for that is that these styles are single-use. So, paperclip becomes a glorified one-time-use image resiszer. I'd prefer not to incur the S3 cost if I don't have to.
Wondering if there'a way to do this out of the box. Or, maybe carrierwave supports something like this?
Thanks!
I'm pretty sure that the Refile library supports it. Refile is basically a modern version of the Carrierwave, written by the same author.
You can read more about the on-the-fly processing here:
https://github.com/refile/refile#processing

Best approach to Users Profile Images in Rails App

I am new to Rails and have been diving into many tutorials and online material. I am now beginning to plan/develop my own app. From all the reading I have done I am yet to come across an industry standard way of handling user profile pictures. I have bullet point what I intend to do (below) and would like some suggestions whether this is a good approach and on the right track or whether there is a much better/secure/standard way:
add a 'ProfilePhotoPath' column to my User Model/Table of type String, which will hold the location path/name of the photo
on sign-up form implement an image upload functionality to upload profile pic and store at specified location (reference in step 1 above)
note: I have come across the 'paperclip gem' and 'imagemagick', is this a better easier approach to what I want to achieve?
There are two better ways to upload profile image using Carrierwave or Paperclip.
If you want to use Carrierwave then refer this tutorial Image Upload using Carrierwave
And if you want to go for Paperclip, then refer this links Upload image using Paperclip video tutorial
Another link with steps is Upload profile image using Paperclip
Most people use Paperclip or a more robust solution would be Carrierwave.
Both are really good. I would tell you to learn Paperclip first.
It's fairly easy if you're just starting out.
Edit: checkout this link. Click the green 'run' button to see the app.
http://runnable.com/UnnhcBiQoFhwAAEb/how-to-upload-files-using-paperclip-for-ruby-on-rails

rails form to pdf and save to amazon s3

I have a form for users to fill out about specific attributes first_name,last_name etc.
I need to generate a pdf from this form and also send an email with the pdf of the form as an attachment.
My approach was to save it to Amazon S3 and somehow attach it in the create method in my controller.
Any input would be greatly appreciated!
You will probably need to use something like the prawn gem https://github.com/prawnpdf/prawn . This will allow you to generate a PDF file from within your application. Your question is somewhat vague though, but you should be able to generate the PDF fairly easily using prawn

Creating a table entry while using CarrierWaveDirect

Is it possible to use something like CarrierWaveDirect to upload directly to S3 and still be able to gather some data on the files being uploaded?
For instance, is it possible to change the filename, and save the size in a table before/after the upload? I don't need to do any kind of manipulation to the file either (I was reading some documentation regarding the use of Resque).
I realize that this is a very novice question but I couldn't find the answer anywhere.
After a lot of fiddling, I found out that the S3 secure upload form that the hidden field success_action_redirect returns so params on the uploaded file.

Resources