![](/img/trans.png)
[英]Rails API Image Upload with Active Storage / S3, React and ActiveAdmin
[英]Ruby on Rails API + VueJS + CKEditor image upload to S3
我的后端有一個Rails API
,前端有一個Vue.JS
應用程序。 有一些功能允許用戶將圖像上傳到 AWS S3(我將Base64
圖像發送到 API 並使用Carrierwave
上傳文件......它就像一個魅力!)
但是現在我必須允許用戶在CKEditor5
編寫文本並將圖像插入正文文本。 最好的方法是如何做到這一點? 我正在考慮在 HTML 正文中發送Base64
圖像並在 API 中提取它們,但我正在尋找更好的方法/想法。
謝謝!
最后,我查看了 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>'
}
}
我正在考慮一個完全瘋狂的解決方案,而不是正確閱讀文檔!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.