我的gatsby站点根目录中的buildspec.yml文件中有以下命令。
version: 0.2
phases:
install:
commands:
- npm i npm@latest -g
- npm install --global gatsby-cli
- npm install
- pip install --upgrade pip
- pip install --upgrade awscli
build:
commands:
- gatsby build
post_build:
commands:
- aws s3 sync public/ s3://stagging
Run Code Online (Sandbox Code Playgroud)
我有2个环境,即停滞和生产。有没有一种方法可以使我的同步命令自动化,以便在执行代码构建时使用某种变量来更改环境。也许我可以通过命令行传递环境名称。
我是 Strapi 的新手,我试图找到一种方法来压缩上传到 Strapi 的图像,然后将其提供给静态 gatsby 站点。有什么办法可以做到这一点吗?我找到了 image-compressor.js npm 库,但我不知道如何将它集成到 Strapi 中,用于每个内容类型的字段和 WYSWYG 编辑器。有人可以帮帮我吗?如果可能,我们可以根据 gatsby 中的显示大小自定义上传到 Strapi 的 it 吗?
第一次尝试集成图像压缩器:
这是我的upload.js:
const Compressor = require('image-compressor')
module.exports = {
upload: async (ctx) => {
// Retrieve provider configuration.
const config = await strapi.store({
environment: strapi.config.environment,
type: 'plugin',
name: 'upload'
}).get({ key: 'provider' });
// Verify if the file upload is enable.
if (config.enabled === false) {
strapi.log.error('File upload is disabled');
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Upload.status.disabled' }] …
Run Code Online (Sandbox Code Playgroud) 我刚刚在我的床模型中将一列'bedNumber'更改为'bed_number',并且我已经更改了控制器和输入字段中的许可但仍然,我得到错误"未定义的方法`bedNumber'#你的意思是什么? bed_number bed_number?bed_number =".有人可以帮我调试一下吗?索引文件与新列名称一起正常工作,唯一的问题是添加和编辑.
这是我的床控制器:
class BedsController < ApplicationController
before_action :set_bed, only: [:show, :edit, :update, :destroy]
# GET /beds
def index
@beds = Bed.all
end
# GET /beds/1
def show
end
# GET /beds/new
def new
@bed = Bed.new
end
# GET /beds/1/edit
def edit
end
# POST /beds
def create
@bed = Bed.new(bed_params)
if @bed.save
redirect_to @bed, notice: 'Bed was successfully created.'
else
render :new
end
end
# PATCH/PUT /beds/1
def update
if @bed.update(bed_params)
redirect_to @bed, notice: 'Bed was …
Run Code Online (Sandbox Code Playgroud) 在 CodeBuild 中,我有 2 个项目。一个用于暂存站点,另一个用于生产站点。当我编译我的网站并通过临时项目运行它时,它工作得很好。它已成功同步到我的暂存站点的 s3 存储桶。但是,当尝试编译它并通过生产项目运行它时,运行同步命令时,它会返回错误:
致命错误:调用 ListObjects 操作时发生错误 (AccessDenied):访问被拒绝
[容器] 2018/09/11 08:40:33 命令未成功退出 aws s3sync public/ s3://$S3_BUCKET 退出状态 1
我做了一些挖掘,我认为问题出在我的存储桶策略上。我使用 CloudFront 作为 S3 存储桶之上的 CDN。我不想修改生产存储桶的存储桶策略,除非我完全确定必须这样做。我担心这可能会对现场产生一些影响。这是我的生产存储桶策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::[bucket_name]/*"
},
{
"Sid": "2",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity [access_code]"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::[bucket_name]/*"
}
]
}
Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services amazon-cloudfront aws-codebuild