我正在尝试使用 terrafrom 配置 AWS Elastic Beanstalk。下面是.tf我写的文件:
resource "aws_s3_bucket" "default" {
bucket = "textX"
}
resource "aws_s3_bucket_object" "default" {
bucket = "${aws_s3_bucket.default.id}"
key = "test-app-version-tf--dev"
source = "somezipFile.zip"
}
resource "aws_elastic_beanstalk_application_version" "default" {
name = "tf-test-version-label"
application = "tf-test-name"
description = "application version created by terraform"
bucket = "${aws_s3_bucket.default.id}"
key = "${aws_s3_bucket_object.default.id}"
}
resource "aws_elastic_beanstalk_application" "tftest" {
name = "tf-test-name"
description = "tf-test-name"
}
resource "aws_elastic_beanstalk_environment" "tfenvtest" {
description = "test"
application = "${aws_elastic_beanstalk_application.tftest.name}"
name = "synchronicity-dev"
cname_prefix = …Run Code Online (Sandbox Code Playgroud) 在我的客户端,我有一个像下面这样的ajax调用:
$.ajax({
url: "Controller/ListResult",
type: 'POST',
contentType: "application/json;charset=utf-8",
data: JSON.stringify({
Id: ObjectId,
SessionKey: sessionManager.getSessionKey()
}),
dataType: "json",
success: function (result) {
var test = results;
}
}
});
Run Code Online (Sandbox Code Playgroud)
在Controller中我有一个像这样的方法:
[HttpPost]
public JsonResult ListResult(string Id, string SessionKey)
{
IBl biz = new BL();
var result = biz.GetResults(Id,SessionKey);
return Json(result);
}
Run Code Online (Sandbox Code Playgroud)
的问题是,其结果是控制器返回是具有少数对象枚举的属性(与他们的字符串表示的值).但是当它在ajax调用中到达success 函数时,枚举不再是字符串表示,而是以某种方式将它们转换为它们的int值.我怎么能避免这个?并保持字符串表示在JavaScript方面.
我的项目中有一个用于我的移动应用程序的后端 API Asp.net Core web Api。
我需要HTML在同一个 webapi 项目中显示两个页面。web api项目中可以有HTML页面吗?如果是的话怎么办?
我有一个 .gitlab-ci.yml 文件,如下所示:
image: node:6.10.3
stages:
- ver
- init
- deploy
ver:
stage: ver
script:
- node --version
- whoami
init:
stage: init
script:
- npm cache clean
- rm -rf node-modules
- npm install
deploy_staging:
stage: deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh-add <(echo "$STAGING_PRIVATE_KEY" …Run Code Online (Sandbox Code Playgroud)我使用 .NET Core 2.2 在我的代码中,我使用IFormFile上传图像。如何在将图像上传到服务器之前将其压缩(以 KB 为单位)?我搜索解决方案,但这些答案与位图有关,但由于我使用的是 IFormFile,因此我想要与之相关的解决方案。
我会在内部检查图像大小,如果它的大小高达 700KB,我不想压缩。但如果它更高,那么我想压缩和上传。示例代码将非常有用
我尝试使用 Magick.NET 包。但问题是,如何将 IFormFile 设为 MagickImage 类型?
foreach(IFormFile photo in Images)
{
using (MagickImage mi = photo) // Cannot implicitly convert type
//Microsoft.AspNetCore.Http.IFormFile to ImageMagick.MagickImage
{
mi.Format = Image.Jpeg;
mi.Resize(40, 40);
mi.Quality = 10;
mi.Write(imageFile);
}
}
Run Code Online (Sandbox Code Playgroud) .tf我的根模块中有两个文件:
第一个被称为api-gateway.tf在 AWS 中提供 API 网关:
resource "aws_apigatewayv2_api" "apiGateway" {
name = "some_Name"
protocol_type = "HTTP"
}
output "api_gateway_endpoint" {
value = "${aws_apigatewayv2_api.apiGateway.api_endpoint}"
}
output "api_gateway_endpoint_id" {
value = "${aws_apigatewayv2_api.apiGateway.id}"
}
Run Code Online (Sandbox Code Playgroud)
我有另一个.tf名为route53.tf创建Route53记录的文件:
resource "aws_route53_record" "www" {
zone_id = "xxxxx"
name = "someurl.com"
type = "A"
alias {
name = "${output.api_gateway_endpoint}"
zone_id = "${output.api_gateway_endpoint_id}"
evaluate_target_health = false
}
}
Run Code Online (Sandbox Code Playgroud)
我需要将 apigateway的api_endpoint和id传递到 route53,但我不知道如何?
我尝试使用output和引用 route53 资源中的返回这两个值,但是它不起作用。它给了我一个undeclared …
我遇到 SSL 证书问题,需要将其绑定到 ELB 实例。
情况如下:
我已在A 区为*.example.com和example.com域注册了通配符 SSL 证书。
A 区域中有一个指向admin.example.com 的ELB 实例,该实例有一个用于 HTTPS 访问的 SSL 证书的 443 侦听器,并且工作正常。
现在,在Region B中,我有另一个新的 ELB 实例,我需要将其指向具有不同子域的相同域。store.example.com
为了实现这一目标,我在第二个区域创建了一个新的 SSL 证书并将其分配给该 ELB。但是,当我尝试打开store.example.com时,我不断看到浏览器显示“不安全”警告
我有一个 Asp.NET Core MVC 应用程序,它Controller总是从View. 我现在通过公开新的 API 端点来扩展应用程序,该端点可以像 Postman 一样从外部调用。
405 - Method Not Allowed当我将[Authorize]属性放在控制器顶部时,我遇到了获取问题。如果没有此属性,我可以到达端点,并且模型将按预期与我从邮递员提供的值绑定。
下面是我的控制器的样子:
[Authorize]
[Route("api/v1/auth")]
public class ApiAuthController : Controller
{
[HttpPost("changePassword")]
public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordModel model)
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
值得一提的是,这个应用程序与提供承载令牌的应用程序是同一个应用程序,我稍后在邮递员中使用它。
在我的Startup.cs文件中,我有以下与IdentityServer和相关的设置Authorization:
services
.AddIdentityServer(options =>
{
options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
})
.AddSigningCredential(cert)
.AddAspNetIdentity<IdentityUser>()
.AddAuthentication()
Run Code Online (Sandbox Code Playgroud) 我有一个名为myGroup的Linq组结果集.myGroup是一种类型
IGrouping <String,myObject>
我试图通过for循环迭代这个.
目前,我可以这样做:
foreach (var item in group)
{
Console.WriteLine(item.Id);
}
Run Code Online (Sandbox Code Playgroud)
如何使用for循环实现相同的功能?
我尝试做类似下面的事情:
for (int i = 0; i < myGroup.Count(); i++)
{
// Now How can I access the current myGroup Item?
//I DO NOT have ElementAt() property in myGroup.
myGroup.ElementAt(i).Id // THIS IS NOT POSSIBLE
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在for循环中访问myGroup当前元素
我的GitLab私有存储区中有一个bash脚本文件。我希望在运行wget命令时在Linux中下载文件,但是由于文件托管在私有存储库中,因此下载失败,因此转到登录页面。
有没有一种方法可以使该单个文件公开访问?如果不是,是否有办法在尝试打开文件时将我的凭据包括在GET URL中?
在Node.JS应用程序中,我试图对不同的端点进行 3 个 API 调用,它们是:
/GET ProductInformation: 返回给定的信息productID。
/GET ProductRecommendation : 返回给定的产品推荐 productID
/GET ProductReview : 返回给定的产品评论和评级 productID
上述调用都不依赖于另一个调用,因此,如果可能,我试图避免Promise像这样的链:
getProductInfo(productId)
.then(result =>{
getProductRecommendation(productId)
.then(result =>{
getProductReview(result => {
callback('done') // all calls are done, we can return now!
})
})
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来进行这种async操作?我想看看是否有更好的方法的原因是因为实际上我有不止 3 个调用,这样做会使代码难以维护和阅读。
我是 ES 的新手,只是想对脑海中的所有内容进行排序。我听说 ES 实际上正在解决写入和读取数据库之间的一致性问题(肯定会有一些延迟)。但我还是不完全明白怎么办?
如果命令进入域并聚合根触发事件以更新事件存储,则将相同的事件发送到更新读取端??但是如果消息丢失了,我们就会有过时的读取端。
是projections唯一的解决方案吗?所以不是从事件更新,而是通过事件存储读取并复制聚合(从开始或从某个快照)。但在这种情况下,它可能违反了一些规则,因为读取端应该很简单,而且它不应该知道域。而且通常读取端是一个单独的应用程序,因此她无法了解聚合。
当然我们也可以使用rabbitMQ或其他一些消息代理来不丢失消息,实际上我认为我们需要。但我也读过,以使其保持一致“你可以使用兔子或 ES”,但是 ES 如何让它自己保持一致?