我的后端有一个Rails API,前端有一个Vue.JS应用。有一些功能,允许用户上传图像到亚马逊应用编程接口(我发送一个Base64图像到S3,并使用Carrierwave上传文件...它的效果就像一种护身符!)
但现在我必须允许用户在CKEditor5中写入文本,并在正文中插入图像。怎样做才是最好的方法呢?我正在考虑发送一个包含在HTML文本中的Base64图像,并在API中提取它们,但我正在寻找一种更好的方法/想法。
谢谢!
发布于 2020-10-23 00:28:10
最后,我在CKEditor文档中找到了这个链接:https://ckeditor.com/docs/ckeditor5/latest/features/image-upload/simple-upload-adapter.html
所以我意识到有一个uploadUrl参数来设置我的后端端点,它应该只返回de AWS S3 url,然后在正文中神奇地被替换掉,瞧!
simpleUpload: {
// The URL that the images are uploaded to.
uploadUrl: 'http://example.com',
// Enable the XMLHttpRequest.withCredentials property.
withCredentials: true,
// Headers sent along with the XMLHttpRequest to the upload server.
headers: {
'X-CSRF-TOKEN': 'CSRF-Token',
Authorization: 'Bearer <JSON Web Token>'
}
}我想的是一个疯狂的解决方案,而不是正确地阅读文档!
https://stackoverflow.com/questions/64464016
复制相似问题