Please Help for Upload image on AWS server in Controller.
I want following things to do.
1. Submit form data with image.
2. Get the image in controller and upload to AWS server.
3. No model coding for upload image to AWS.
Instead of write code in model as below
has_mongoid_attached_file :avatar, {
path: ':class/:id/:style/:basename.:extension',
storage: :s3,
bucket: bucket_name,
s3_credentials: {
access_key_id: 'access_key_id',
secret_access_key: 'secret_access_key'
},
styles: {
thumb: ['90x90^', :jpg],
feature: ['220x142^', :jpg],
show_page: ['720x420^', :jpg],
preview: ['145x90^', :jpg]
}
}
I want to upload image directly from controller.
and only save the URL of uploaded image in database instead of below.
"attachment_file_name": "imagename.png",
"attachment_content_type": "image/png",
"attachment_file_size": 1235,
"attachment_updated_at": TimeStamp,
i want to store only URL like this
avatar = https://s3.amazonaws.com/bucket_name/imagename.png
NOTE: My project in Rails 3.1.12 , Ruby 1.9.3p484 using mongoid
You need to pass url option in model , like this