Sha256: 4ab58379c409f411703cdc07257318f0f27f4d86f577550cab2f53e19d7311ae
Contents?: true
Size: 897 Bytes
Versions: 4
Compression:
Stored size: 897 Bytes
Contents
module PostmanMta class AttachmentsController < ApplicationController include ActionController::DataStreaming def show response = attachment.find(params[:uuid]).deep_symbolize_keys file = response.dig(:json, :attachment) if file[:body].present? send_attachment(file) else proxy_attachment(file) end end private def attachment @attachment ||= PostmanMta::Attachment.new(params[:message_token]) end def send_attachment(file) file_data = Base64.decode64(file[:body]) send_data(file_data, type: file[:content_type], filename: file[:filename], dispostion: 'attachment') end def proxy_attachment(file) headers['X-Accel-Redirect'] = PostmanMta::Utils::SendfileUrl.new(file[:url]).to_url headers['Content-Disposition'] = "attachment; filename=\"#{file[:filename]}\"" end end end
Version data entries
4 entries across 4 versions & 1 rubygems