node.js - 如何使用 ckeditor 在 mongoose-node 应用程序中上传图像。文件将上传到 s3
问题描述
我正在使用 CKEditor 在猫鼬中上传内容。我希望图像与内容一起上传。我将图像存储到 s3 并且 mongodb 将图像路径存储在字符串中(当不使用 ckeditor 上传时)。
我正在尝试使用这个模块 https://github.com/mjadobson/ckeditor5-sss-upload
我正在尝试这段代码
构建-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"
]
}
// ...
}
};
研讨会.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(在细节之间)。
请帮忙。如果有其他方法请回复
解决方案
推荐阅读
- batch-file - 如何在一组文件夹中找到许多最新文件?
- php - 如何在数据库中输入数据?
- python - Python Facebook SDK 示例 - ModuleNotFoundError
- r - 如何增加 R 中的 ram 使用量以使用 foreach 进行并行编程
- c# - 在另一个文件中声明类时导入类 - 打字机
- json - 如何从具有 4 级多级索引的 pandas 数据框中获取嵌套 JSON?
- python - 提交更改后如何在我的电脑上本地运行 python github 存储库?
- python - Cerberus META 验证规则访问
- reactjs - 使用 ReactSelector for TestCafe 时,不断收到 `ReExecutablePromise { _then: [], _fn: [Function], _taskPromise: null }`
- ansible - 如何根据条件循环多个任务