Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Fileupload custom action #41

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

codingluke
Copy link

Hi @ejholmes

Here another feature. I just added the possibility also to provide an custom uploader action. I added this because I like to scale down images before they gets saved at S3. I just don't believe enough in the editors that they don't put a 3MB Image in. All the tests still run and new ones are added.

ActiveAdmin::Editor.configure do |config|
  config.uploader_action_path = '/admin/posts/upload_image'
end

example action

collection_action :upload_image, :method => :post do
  img = ImageUploader.new(image: params[:file])
  img.upload

  # IMPORTANT the image url must be set as the headers location porperty
  render json: {location: img.remote_url} , location: img.remote_url
end

Cheers

@ejholmes
Copy link
Owner

This looks awesome! If you wouldn't mind squashing the commits, I'll merge this.

@codingluke
Copy link
Author

great I will do it tomorrow at work.

@julionc
Copy link
Contributor

julionc commented May 6, 2015

cc @codingluke

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants