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

19 lines
618 B

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