闭社主体 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.

16 lines
562 B

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