1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/controllers/api/files_controller.rb
Sylvain 5c152412db test mime type of a file
use marcel to test mime types
updated mimemagic
2020-06-03 16:25:13 +02:00

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