我在我的 Angular 4 应用程序中实现了 Froala 编辑器。我尝试在 AWS S3 上上传图像,但出现 CORS 错误。 这是我的文件。
服务器端(生成签名):
'use strict';
var FroalaEditor = require('../../node_modules/wysiwyg-editor-node-
sdk/lib/froalaEditor.js');
module.exports = function(server) {
var router = server.loopback.Router();
router.get('/api/get_signature', function(req, res) {
var configs = {
bucket: 'bucket',
region: 's3',
// The folder where to upload the images.
keyStart: 'email',
// File access.
acl: 'public-read',
// AWS keys.
accessKey: 'xxxxxxx',
secretKey: 'xxxxxxxxxx'
}
var s3Hash = FroalaEditor.S3.getHash(configs);
res.send(s3Hash);
});
server.use(router);
}
这是我的 Angular 组件文件:
//initialize froala after getting the signature
public initialize(initControls) {
this.froala = initControls;
this._RestService.getEditorSignature().subscribe(
d => {
this.editorOptions['imageUploadToS3'] = d;
this.froala.initialize();
});
}
这是我的 Cors 配置:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>http://localhost:4200</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authoriz</AllowedHeader>
</CORSRule>
</CORSConfiguration>
我也尝试过在 and 中使用“*”,但仍然无法正常工作。 谁能告诉我正确的方向?
最佳答案
实际上一切正常。我将区域从 s3 更改为 ap-south-1。 我误判了 bucket 区域。
关于javascript - Froala 编辑器 AWS S3 CORS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51273675/