Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Storage): S3 bucket instead of EC2 storage for images and thumbnails #17

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 42 additions & 29 deletions config/middlewares.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
export default [
'strapi::errors',
{
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "https:"],
"img-src": ["'self'", "data:", "blob:", "*"],
"media-src": ["'self'", "data:", "blob:", "*"],
"default-src":["'self'"],
"script-src": ["'self'", "'unsafe-inline'"],
upgradeInsecureRequests: null,
export default ({ env }) => (
[
'strapi::errors',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': [
"'self'",
'data:',
'blob:',
'market-assets.strapi.io',
env('AWS_BUCKET_ENDPOINT'),

],
'media-src': [
"'self'",
'data:',
'blob:',
'market-assets.strapi.io',
env('AWS_BUCKET_ENDPOINT'),
],
upgradeInsecureRequests: null,
},
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
{
name: 'strapi::favicon',
config: {
path: './src/admin/extensions/trackit.png'
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
{
name: 'strapi::favicon',
config: {
path: './src/admin/extensions/trackit.png'
},
},
'strapi::public',
];
'strapi::public',
]
);
52 changes: 36 additions & 16 deletions config/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
export default {
// ...
'cloudfront-metrics': {
enabled: true,
resolve: './src/plugins/cloudfront-metrics'
},
'custom-selects': {
enabled: true,
resolve: './src/plugins/custom-selects'
},
'docusaurus': {
enabled: true,
resolve: './src/plugins/docusaurus'
},
// ...
}
export default async ({ env }) => {

return {
upload: {
config: {
provider: 'aws-s3',
providerOptions: {
s3Options: {
region: env('AWS_REGION'),
params: {
ACL: 'private', // <== set ACL to private
Bucket: env('AWS_BUCKET'),
},
},
},
actionOptions: {
upload: {},
uploadStream: {},
delete: {},
},
},
},
'cloudfront-metrics': {
enabled: true,
resolve: './src/plugins/cloudfront-metrics'
},
'custom-selects': {
enabled: true,
resolve: './src/plugins/custom-selects'
},
'docusaurus': {
enabled: true,
resolve: './src/plugins/docusaurus'
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@strapi/plugin-documentation": "4.12.0",
"@strapi/plugin-i18n": "4.12.0",
"@strapi/plugin-users-permissions": "4.12.0",
"@strapi/provider-upload-aws-s3": "^4.15.4",
"@strapi/strapi": "4.12.0",
"async_hooks": "^1.0.0",
"chart.js": "^4.3.3",
Expand Down
13 changes: 13 additions & 0 deletions patches/@strapi+provider-upload-aws-s3+4.15.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/@strapi/provider-upload-aws-s3/dist/index.js b/node_modules/@strapi/provider-upload-aws-s3/dist/index.js
index 6cec5cd..817ce80 100644
--- a/node_modules/@strapi/provider-upload-aws-s3/dist/index.js
+++ b/node_modules/@strapi/provider-upload-aws-s3/dist/index.js
@@ -69,7 +69,7 @@ const extractCredentials = (options) => {
secretAccessKey: options.s3Options.credentials.secretAccessKey
};
}
- throw new Error("Couldn't find AWS credentials.");
+ return undefined;
};
const assertUrlProtocol = (url) => {
return /^\w*:\/\//.test(url);
Loading