【问题标题】:Froala Editor AWS S3 CORS issueFroala 编辑器 AWS S3 CORS 问题
【发布时间】:2018-11-18 15:27:15
【问题描述】:

我已经在我的 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);
}

这是我的角度组件文件:

  //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>

在所有这些之后我仍然得到这个错误

我也尝试过在其中使用“*”,但仍然无法正常工作。 谁能把我引向正确的方向?

【问题讨论】:

    标签: javascript angular amazon-web-services amazon-s3 froala


    【解决方案1】:

    实际上一切正常。我将区域从 s3 更改为 ap-south-1。 我误判了bucket区域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-01
      • 2021-02-17
      • 2019-04-21
      • 1970-01-01
      • 2019-01-23
      • 2020-02-20
      • 2018-12-21
      • 1970-01-01
      相关资源
      最近更新 更多