media_controller.rb 605 B

12345678910111213
  1. # frozen_string_literal: true
  2. class Api::V2::MediaController < Api::V1::MediaController
  3. def create
  4. @media_attachment = current_account.media_attachments.create!({ delay_processing: true }.merge(media_attachment_params))
  5. render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: @media_attachment.not_processed? ? 202 : 200
  6. rescue Paperclip::Errors::NotIdentifiedByImageMagickError
  7. render json: file_type_error, status: 422
  8. rescue Paperclip::Error => e
  9. Rails.logger.error "#{e.class}: #{e.message}"
  10. render json: processing_error, status: 500
  11. end
  12. end