小编Har*_*uwa的帖子

更新在 Terraform 文件中创建的存储桶会导致 BucketAlreadyOwnedByYou 错误

我需要将策略添加到我之前在 Terraform 文件中创建的存储桶。

但是,这个错误与

创建 S3 存储桶时出错:BucketAlreadyOwnedByYou:您之前创建指定存储桶的请求已成功,并且您已拥有该存储桶。

如何修改 .tf 文件来创建存储桶,然后更新它?

resource "aws_s3_bucket" "bucket" {
  bucket = "my-new-bucket-123"
  acl    = "public-read"

  region = "eu-west-1"

  website {
    index_document = "index.html"
  }
}

data "aws_iam_policy_document" "s3_bucket_policy_document" {
  statement {
    actions   = ["s3:GetObject"]
    resources = ["${aws_s3_bucket.bucket.arn}/*"]
    principals {
      type        = "AWS"
      identifiers = ["*"]
    }
  }
}

resource "aws_s3_bucket" "s3_bucket_policy" {
  bucket = "${aws_s3_bucket.bucket.bucket}"
  policy = "${data.aws_iam_policy_document.s3_bucket_policy_document.json}"
}
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-aws

7
推荐指数
1
解决办法
8471
查看次数

错误:由于 MIME 类型(“text/html”)不匹配而被阻止(X-Content-Type-Options:nosniff)

我正在尝试使用 express 和 ajax 在测试站点上测试一些 api 调用,但是如果我将 js 脚本分成自己的文件,则会出现以下错误,

由于 MIME 类型(“text/html”)不匹配(X-Content-Type-Options:nosniff),来自“ http://localhost:9000/userProfileFunctions.js ”的资源被阻止。

如果我将所有内容都保存在同一个 html 文件中,它会起作用,但这更像是解决问题的创可贴。我什至将 express app.use 标头设置为“X-Content-Type-Options: nosniff”,但它仍然不起作用

主文件

<html>

<head>
    <script
            src="https://code.jquery.com/jquery-3.4.1.min.js"
            integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
            crossorigin="anonymous">
    </script>

    <script src="userProfileFunctions.js" ></script>

</head>
<body>
    <form>
        <h4>GET REQUEST USERS PROFILE</h4>
        UUID: <input id="getUserInput" type="text" name="UUID"><br>
        <input id="getUserProfile" type="button" value="submit">
    </form>
</body>
</html>

Run Code Online (Sandbox Code Playgroud)

应用程序.js

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery express

6
推荐指数
2
解决办法
1万
查看次数

将类型转换为不同类型时出现打字稿错误

我只是想更好地了解以下错误:

将类型“A”转换为类型“B”可能是错误的,因为两种类型都没有与另一种类型充分重叠。

然后当我尝试做一些测试时,我遇到了一个奇怪的错误。

这些是我们的代码:

type User = {
  id: string
  username: string
  age?: number
}

const user1 = {
  id: '123',
  username: 'user',
} as User // OK

const user2 = {
  id: '123',
  username: 'user',
  age: 5
} as User // OK

const user3 = {
  id: '123',
  username: 'user',
  age: 5,
  email: '1234'
} as User // OK

const user4 = {
  id: '123',
  username: 'user',
  age: '5',
} as User // Error, the age type is different …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

6
推荐指数
1
解决办法
6028
查看次数

如何使用 Angular 和 ASP.Net Core 在字节数组 [] 中转换文件并存储在数据库中?

我是 angular 的新手,并且被困在 angular 中进行文件上传

技术:Angular、ASP.Net Core、Sqlserver

我需要在我的 Angular 应用程序中添加文件上传功能,其中服务位于 ASP.Net Core 中,而服务文件上传数据类型位于 Byte[]

我有如下形式 在此处输入图片说明

我需要单击保存按钮将所有数据保存在数据库中,并在字节 [] 中转换文件并存储在数据库中

提前谢谢你们

c# sql-server file-upload asp.net-core angular

1
推荐指数
1
解决办法
9142
查看次数