我正在使用CKEditor上载猫鼬的内容。 我希望图像与内容一起上传。 我将图像存储到s3,而mongodb将图像路径存储在字符串中(当不使用ckeditor上传时)。
我正在尝试使用此模块 https://github.com/mjadobson/ckeditor5-sss-upload
我正在尝试这段代码
build-config.js
module.exports = {
// ...
plugins: [
"@ckeditor/ckeditor5-essentials/src/essentials",
// ...
//'@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter',
//'@ckeditor/ckeditor5-easy-image/src/easyimage',
"ckeditor5-sss-upload/src/s3upload"
// ...
],
// ...
config: {
toolbar: {
items: [
"headings",
"bold",
"italic",
"imageUpload",
"link",
"bulletedList",
"numberedList",
"blockQuote",
"undo",
"redo"
]
}
// ...
}
};
seminar.js
const build_config=require('../build-config');
router.get('/add',ensureAuthenticated,(req,res)=>{
SeminarGamenameConf.find().then(gameName_list=>{
SeminarGametypeConf.find().then(gameType_list=>{
console.log(gameType_list);
res.render('cms/seminar/add',{
gameName_list_array:gameName_list,
gameType_list_array:gameType_list,
country: countries,
build_config:build_config
});
})
})
});
// add.handlebars
<script src="/ckeditor5-build-classic/ckeditor.js"></script>
<form action="/cms/seminar/add" enctype="multipart/form-data" method="post" >
<div class="form-group">
<label for="seminar_detail">Seminar Details</label>
<textarea class="form-control" id="editor1" name="seminar_detail</textarea>
<input type="submit" value="submit"/>
</div>
</form>
<script>
ClassicEditor.create(document.querySelector("#editor"), {
s3Upload: {
policyUrl: "http://127.0.0.1/my-upload-endpoint",
mapUrl: ({ location, bucket, key }) => {
return location;
}
}
});
</script>
我真的很困惑。我不知道如何使用ckeditor(在细节之间)将图像上传到s3。
请帮助。 如果还有其他方法,请回复