我在通过put方法上传图像后尝试通过get方法显示图像。这是我的get方法:
@visitImageController.route('/getVisitImage', methods=['GET'])
def getVisitImage():
try:
print('getVisitImage controller')
return send_file(os.path.join(current_app.config['fileUploadPath'], request.args.get('visitImagePath')),
mimetype='image/png')
except Exception as e:
print(e)
return Response(json.dumps({'status': 'failed', 'message': 'data failed to update.'}),
status=200, mimetype='application/json')
这是我编写的用于在前端显示图像的代码
axios.get(this.state.apiUrl + '/api/v1/visitImage/getVisitImage',
{}, {})
.then((response) => {
console.log('getonebyid colling ...');
console.log("response", response.data.data);
const responseData = response.data.data;
this.setState({
imagePath: this.state.apiUrl +'/api/v1/visitImage/getVisitImage?visitImagePath='+ responseData.imagePath
});
}).catch((error) => {
console.log("error", error);
});
图片上传正常。但是当我尝试在后端显示图片时出现此错误:
join() argument must be str or bytes, not 'nonetype'
它还在控制台中显示未定义的图像路径。如何解决此错误?