mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
5c152412db
use marcel to test mime types updated mimemagic
21 lines
436 B
Ruby
21 lines
436 B
Ruby
# frozen_string_literal: true
|
|
|
|
# API Controller for handling special actions on files
|
|
class API::FilesController < API::ApiController
|
|
before_action :authenticate_user!
|
|
|
|
# test the mime type of the uploaded file
|
|
def mime
|
|
authorize :file
|
|
|
|
content_type = Marcel::MimeType.for Pathname.new(file_params.path)
|
|
render json: { type: content_type }
|
|
end
|
|
|
|
private
|
|
|
|
def file_params
|
|
params.require(:attachment)
|
|
end
|
|
end
|