def get_files(): if request.headers.get("Authorization") != Config.auth_token: return jsonify({"message": "Invalid auth_token"}) data = request.json file_type = data.get("file_type", None) if not file_type: return jsonify({"message": "file_type not supplied"}) num_files = data.get("num_files", 1) output_file = FileService.get_files(file_type, num_files) if not output_file: return jsonify({"message": "no files present"}) else: return send_file( output_file, attachment_filename=output_file, as_attachment=True )
def get_file(**kwargs): file_path = FileService.get_files(kwargs["type"], kwargs.get("num_files", 1)) with open(file_path, "rb") as content_file: content = content_file.read() return content # .encode()