闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
489 B

  1. class Api::V1::MediaController < ApiController
  2. before_action :doorkeeper_authorize!
  3. respond_to :json
  4. def create
  5. @media = MediaAttachment.create!(account: current_user.account, file: params[:file])
  6. rescue Paperclip::Errors::NotIdentifiedByImageMagickError
  7. render json: { error: 'File type of uploaded media could not be verified' }, status: 422
  8. rescue Paperclip::Error
  9. render json: { error: 'Error processing thumbnail for uploaded media' }, status: 500
  10. end
  11. end