javascript - Froala 编辑器 AWS S3 CORS 问题

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

我在我的 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>

在所有这些之后我仍然得到这个错误 enter image description here

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

最佳答案

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

关于javascript - Froala 编辑器 AWS S3 CORS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51273675/

相关文章:

javascript - Win 8 应用程序开发 : How does this tutorial code work?

javascript - 为什么这个函数不使数组为空?

javascript - 无法将 div 准确定位在另一个元素上

html - 如何使用 React/Angular/Vue 使 </div> 更接近其 <div>?

amazon-web-services - 是否可以更改Amazon S3响应 header `Server`?

javascript - Polymer-Project 对象未在 OS X 10.10 中呈现

angular - 带有 Typescript 错误 TS18003 的 Npm 服务器

angular - 手动将表单设置为无效 Angular 2+

amazon-web-services - KAFKA 代理抛出错误的请求类型 18 和错误的请求类型 16

caching - Amazon S3 命令行将所有对象复制到自己设置缓存控制