我有一个简单的Angular SPA项目,该项目从AWS S3存储桶中托管。
存储桶中的对象需要一些元数据标签(内容类型,缓存控件等),以确保内容正确加载并经常更新。
[我正在使用AWS代码构建,使用下面的buildspec.yml文件将项目部署到S3存储桶:
version: 0.2
phases:
pre_build:
commands:
- echo Starting Build Now
- npm install
build:
commands:
- echo Build ready for manufacturing of the artifact
- npm build
post_build:
commands:
- aws s3 sync $BUILD_OUTPUT_LOCATION s3://$BUCKET_NAME --delete
- echo Build completed successfully
在此buildspec.yml文件的后期构建中,是否有命令将必要的元数据标签添加到要同步的文件中的S3存储桶中?
使用参数直接从aws cli添加元标记,类似:
$ aws s3 cp s3://bucketname/ s3://bucketname/ --recursive --metadata-directive REPLACE --cache-control max-age=86400
$ aws s3 sync $BUILD_OUTPUT_LOCATION s3://$BUCKET_NAME --delete --cache-control max-age=86400