def get_ticket_attachment(ticket=None, attachment=None): """ Get `abuse.models.Ticket`'s `abuse.models.AttachedDocument` """ code, resp = TicketsController.get_attachment(ticket, attachment) if code != 200: return make_response(json.dumps(resp), code, {'content-type': 'application/json'}) bytes_io = BytesIO(resp['raw']) return send_file(bytes_io, attachment_filename=resp['filename'], mimetype=resp['filetype'], as_attachment=True)