def post(self, request): img = request.data.get("api_img_upload", None) dir_name = request.data.get('dirname', '') base_img = request.data.get('base', None) if img: result = img_upload(img, dir_name, request.user) resp = {'code': 0, 'data': result['url']} elif base_img: result = base_img_upload(base_img, dir_name, request.user) resp = {'code': 0, 'data': result['url']} else: resp = {"code": 5, "message": "出错信息"} return Response(resp)
def post(self, request): img = request.data.get("api_img_upload", None) # 编辑器上传 # manage_upload = request.data.get('manage_upload', None) # 图片管理上传 dir_name = request.data.get('dirname', '') base_img = request.data.get('base', None) if img: # 上传普通图片文件 result = img_upload(img, dir_name, request.user) resp = {'code': 0, 'data': result['url']} # elif manage_upload: # result = img_upload(manage_upload, dir_name, request.user) # resp = {'code': 0, 'data': result['url']} elif base_img: # 上传base64编码图片 result = base_img_upload(base_img, dir_name, request.user) resp = {'code': 0, 'data': result['url']} else: resp = {"code": 5, "message": _("出错信息")} return Response(resp)