{"_id":"@bilberrry/strapi-provider-upload-s3","_rev":"1-92d634d1984d61836a44a4086d99df3b","name":"@bilberrry/strapi-provider-upload-s3","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@bilberrry/strapi-provider-upload-s3","version":"1.0.0","keywords":["upload","aws","s3","strapi"],"author":{"url":"https://strapi.io","name":"Strapi Solutions SAS","email":"hi@strapi.io"},"license":"SEE LICENSE IN LICENSE","_id":"@bilberrry/strapi-provider-upload-s3@1.0.0","maintainers":[{"name":"nick-bilberrry","email":"nick@bilberrry.com"},{"name":"bohdan.p","email":"bohdan@bilberrry.com"},{"name":"garretua","email":"alex.mukho@gmail.com"}],"homepage":"https://strapi.io","bugs":{"url":"https://github.com/strapi/strapi/issues"},"dist":{"shasum":"6335774a912a29eae24234c8f6d54dfc17b9cc43","tarball":"https://registry.npmjs.org/@bilberrry/strapi-provider-upload-s3/-/strapi-provider-upload-s3-1.0.0.tgz","fileCount":3,"integrity":"sha512-JviO7YpmyNoEe4QLMXEAcxx+YDdu0rQCnjutsaNWvrQIMNb0Aq9UILz14OWRrZu19zJHgEhrMgEXB9MxEeRb0Q==","signatures":[{"sig":"MEUCIQCOebC7ymbIi6Nisg3iAfVVSgcZeMP99fD9cmfm3aKKVgIgGZkBO8truEY2cqmKZSDKil/nmI3SNimu0Nqk+Y1qNuU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13866},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","source":"./src/index.ts","engines":{"npm":">=6.0.0","node":">=18.0.0 <=20.x.x"},"gitHead":"32224823901e9493b34ff800878df9051e7bc0e9","scripts":{"lint":"run -T eslint .","build":"pack-up build","clean":"run -T rimraf ./dist","watch":"pack-up watch","test:unit":"run -T jest","test:unit:watch":"run -T jest --watch"},"_npmUser":{"name":"garretua","email":"alex.mukho@gmail.com"},"repository":{"url":"git://github.com/strapi/strapi.git","type":"git"},"_npmVersion":"10.2.4","description":"AWS S3 provider for strapi upload with IAM roles support","directories":{},"_nodeVersion":"20.11.0","dependencies":{"@aws-sdk/client-s3":"3.614.0","@aws-sdk/lib-storage":"3.614.0","@aws-sdk/s3-request-presigner":"3.614.0"},"_hasShrinkwrap":false,"devDependencies":{"tsconfig":"5.0.0-rc.7","@types/jest":"29.5.2","@strapi/pack-up":"5.0.0","eslint-config-custom":"5.0.0-rc.7"},"_npmOperationalInternal":{"tmp":"tmp/strapi-provider-upload-s3_1.0.0_1723718050336_0.918249378440428","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@bilberrry/strapi-provider-upload-s3","version":"1.0.1","description":"AWS S3 provider for strapi upload with IAM roles support","keywords":["upload","aws","s3","strapi"],"homepage":"https://strapi.io","bugs":{"url":"https://github.com/strapi/strapi/issues"},"repository":{"type":"git","url":"git://github.com/strapi/strapi.git"},"license":"SEE LICENSE IN LICENSE","author":{"name":"Strapi Solutions SAS","email":"hi@strapi.io","url":"https://strapi.io"},"maintainers":[{"name":"nick-bilberrry","email":"nick@bilberrry.com"},{"name":"bohdan.p","email":"bohdan@bilberrry.com"},{"name":"garretua","email":"alex.mukho@gmail.com"}],"main":"./dist/index.js","module":"./dist/index.mjs","source":"./src/index.ts","types":"./dist/index.d.ts","scripts":{"build":"pack-up build","clean":"run -T rimraf ./dist","lint":"run -T eslint .","test:unit":"run -T jest","test:unit:watch":"run -T jest --watch","watch":"pack-up watch"},"dependencies":{"@aws-sdk/client-s3":"3.614.0","@aws-sdk/lib-storage":"3.614.0","@aws-sdk/s3-request-presigner":"3.614.0"},"devDependencies":{"@strapi/pack-up":"5.0.0","@types/jest":"29.5.2","eslint-config-custom":"5.0.0-rc.7","tsconfig":"5.0.0-rc.7"},"engines":{"node":">=18.0.0 <=20.x.x","npm":">=6.0.0"},"_id":"@bilberrry/strapi-provider-upload-s3@1.0.1","gitHead":"fe4f315a129e3e8042ed0ab5ebf556cd94ad92d8","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-J5tyg61MSCYY9CsESd6oT2foAyF8Cr+CJe4YCKoX0TArF+e5NjASd7FVJ7Ztg8GopmusE5Ykvmlintzo+WOUow==","shasum":"9173070ba8a650395b0f1d5ef89abe7edbbc5f24","tarball":"https://registry.npmjs.org/@bilberrry/strapi-provider-upload-s3/-/strapi-provider-upload-s3-1.0.1.tgz","fileCount":9,"unpackedSize":41949,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEv9wD/dVcg0UZmqlzmqM+pa3eZ8F3/lNPxDm6gJZ/ZwAiEAhI2e1rtJASE7M0EjHzgtibB+E49zpGGrr2KCHBgq94c="}]},"_npmUser":{"name":"garretua","email":"alex.mukho@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strapi-provider-upload-s3_1.0.1_1723722262681_0.5874972312669509"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-15T10:34:10.236Z","modified":"2024-08-15T11:44:23.125Z","1.0.0":"2024-08-15T10:34:10.504Z","1.0.1":"2024-08-15T11:44:22.896Z"},"bugs":{"url":"https://github.com/strapi/strapi/issues"},"author":{"name":"Strapi Solutions SAS","email":"hi@strapi.io","url":"https://strapi.io"},"license":"SEE LICENSE IN LICENSE","homepage":"https://strapi.io","keywords":["upload","aws","s3","strapi"],"repository":{"type":"git","url":"git://github.com/strapi/strapi.git"},"description":"AWS S3 provider for strapi upload with IAM roles support","maintainers":[{"name":"nick-bilberrry","email":"nick@bilberrry.com"},{"name":"bohdan.p","email":"bohdan@bilberrry.com"},{"name":"garretua","email":"alex.mukho@gmail.com"}],"readme":"# @strapi/provider-upload-aws-s3\n\n## Resources\n\n- [LICENSE](LICENSE)\n\n## Links\n\n- [Strapi website](https://strapi.io/)\n- [Strapi documentation](https://docs.strapi.io)\n- [Strapi community on Discord](https://discord.strapi.io)\n- [Strapi news on Twitter](https://twitter.com/strapijs)\n\n## Installation\n\n```bash\n# using yarn\nyarn add @strapi/provider-upload-aws-s3\n\n# using npm\nnpm install @strapi/provider-upload-aws-s3 --save\n```\n\n## Configuration\n\n- `provider` defines the name of the provider\n- `providerOptions` is passed down during the construction of the provider. (ex: `new AWS.S3(config)`). [Complete list of options](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property)\n- `providerOptions.params` is passed directly to the parameters to each method respectively.\n  - `ACL` is the access control list for the object. Defaults to `public-read`.\n  - `signedUrlExpires` is the number of seconds before a signed URL expires. (See [how signed URLs work](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-signed-urls.html)). Defaults to 15 minutes and URLs are only signed when ACL is set to `private`.\n  - `Bucket` is the name of the bucket to upload to.\n- `actionOptions` is passed directly to the parameters to each method respectively. You can find the complete list of [upload/ uploadStream options](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property) and [delete options](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteObject-property)\n\nSee the [documentation about using a provider](https://docs.strapi.io/developer-docs/latest/plugins/upload.html#using-a-provider) for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to the [documentation about environment variables](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#environment-variables).\n\nIf you're using the bucket as a CDN and deliver the content on a custom domain, you can get use of the `baseUrl` and `rootPath` properties to configure how your assets' urls will be saved inside Strapi.\n\n### Provider Configuration\n\n`./config/plugins.js` or `./config/plugins.ts` for TypeScript projects:\n\n```js\nmodule.exports = ({ env }) => ({\n  // ...\n  upload: {\n    config: {\n      provider: 'aws-s3',\n      providerOptions: {\n        baseUrl: env('CDN_URL'),\n        rootPath: env('CDN_ROOT_PATH'),\n        s3Options: {\n          credentials: {\n            accessKeyId: env('AWS_ACCESS_KEY_ID'),\n            secretAccessKey: env('AWS_ACCESS_SECRET'),\n          },\n          region: env('AWS_REGION'),\n          params: {\n            ACL: env('AWS_ACL', 'public-read'),\n            signedUrlExpires: env('AWS_SIGNED_URL_EXPIRES', 15 * 60),\n            Bucket: env('AWS_BUCKET'),\n          },\n        },\n      },\n      actionOptions: {\n        upload: {},\n        uploadStream: {},\n        delete: {},\n      },\n    },\n  },\n  // ...\n});\n```\n\n### Configuration for a private S3 bucket and signed URLs\n\nIf your bucket is configured to be private, you will need to set the `ACL` option to `private` in the `params` object. This will ensure file URLs are signed.\n\n**Note:** If you are using a CDN, the URLs will not be signed.\n\nYou can also define the expiration time of the signed URL by setting the `signedUrlExpires` option in the `params` object. The default value is 15 minutes.\n\n`./config/plugins.js`\n\n```js\nmodule.exports = ({ env }) => ({\n  // ...\n  upload: {\n    config: {\n      provider: 'aws-s3',\n      providerOptions: {\n        credentials: {\n          accessKeyId: env('AWS_ACCESS_KEY_ID'),\n          secretAccessKey: env('AWS_ACCESS_SECRET'),\n        },\n        region: env('AWS_REGION'),\n        params: {\n          ACL: 'private', // <== set ACL to private\n          signedUrlExpires: env('AWS_SIGNED_URL_EXPIRES', 15 * 60),\n          Bucket: env('AWS_BUCKET'),\n        },\n      },\n      actionOptions: {\n        upload: {},\n        uploadStream: {},\n        delete: {},\n      },\n    },\n  },\n  // ...\n});\n```\n\n#### Configuration for S3 compatible services\n\nThis plugin may work with S3 compatible services by using the `endpoint`. Scaleway example:\n`./config/plugins.js`\n\n```js\nmodule.exports = ({ env }) => ({\n  // ...\n  upload: {\n    config: {\n      provider: 'aws-s3',\n      providerOptions: {\n        credentials: {\n          accessKeyId: env('SCALEWAY_ACCESS_KEY_ID'),\n          secretAccessKey: env('SCALEWAY_ACCESS_SECRET'),\n        },\n        region: env('SCALEWAY_REGION'), // e.g \"fr-par\"\n        endpoint: env('SCALEWAY_ENDPOINT'), // e.g. \"https://s3.fr-par.scw.cloud\"\n        params: {\n          Bucket: env('SCALEWAY_BUCKET'),\n        },\n      },\n    },\n  },\n  // ...\n});\n```\n\n### Security Middleware Configuration\n\nDue to the default settings in the Strapi Security Middleware you will need to modify the `contentSecurityPolicy` settings to properly see thumbnail previews in the Media Library. You should replace `strapi::security` string with the object bellow instead as explained in the [middleware configuration](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html#loading-order) documentation.\n\n`./config/middlewares.js`\n\n```js\nmodule.exports = [\n  // ...\n  {\n    name: 'strapi::security',\n    config: {\n      contentSecurityPolicy: {\n        useDefaults: true,\n        directives: {\n          'connect-src': [\"'self'\", 'https:'],\n          'img-src': [\n            \"'self'\",\n            'data:',\n            'blob:',\n            'market-assets.strapi.io',\n            'yourBucketName.s3.yourRegion.amazonaws.com',\n          ],\n          'media-src': [\n            \"'self'\",\n            'data:',\n            'blob:',\n            'market-assets.strapi.io',\n            'yourBucketName.s3.yourRegion.amazonaws.com',\n          ],\n          upgradeInsecureRequests: null,\n        },\n      },\n    },\n  },\n  // ...\n];\n```\n\nIf you use dots in your bucket name (`forcePathStyle set to false`), the url of the resource is in directory style (`s3.yourRegion.amazonaws.com/your.bucket.name/image.jpg`) instead of `yourBucketName.s3.yourRegion.amazonaws.com/image.jpg` so in that case the img-src and media-src directives to add will be `s3.yourRegion.amazonaws.com` without the bucket name in the url.\n\n## Bucket CORS Configuration\n\nIf you are planning on uploading content like GIFs and videos to your S3 bucket, you will want to edit its CORS configuration so that thumbnails are properly shown in Strapi. To do so, open your Bucket on the AWS console and locate the _Cross-origin resource sharing (CORS)_ field under the _Permissions_ tab, then amend the policies by writing your own JSON configuration, or copying and pasting the following one:\n\n```json\n[\n  {\n    \"AllowedHeaders\": [\"*\"],\n    \"AllowedMethods\": [\"GET\"],\n    \"AllowedOrigins\": [\"YOUR STRAPI URL\"],\n    \"ExposeHeaders\": [],\n    \"MaxAgeSeconds\": 3000\n  }\n]\n```\n\n## Required AWS Policy Actions\n\nThese are the minimum amount of permissions needed for this provider to work.\n\n```json\n\"Action\": [\n  \"s3:PutObject\",\n  \"s3:GetObject\",\n  \"s3:ListBucket\",\n  \"s3:DeleteObject\",\n  \"s3:PutObjectAcl\"\n],\n```\n\n## Update to AWS SDK V3 and URL Format Change\n\nIn the recent update of the `@strapi/provider-upload-aws-s3` plugin, we have transitioned from AWS SDK V2 to AWS SDK V3. This significant update brings along a change in the format of the URLs used in Amazon S3 services.\n\n### Understanding the New URL Format\n\nAWS SDK V3 adopts the virtual-hosted–style URI format for S3 URLs. This format is recommended by AWS and is likely to become required in the near future, as the path-style URI is being deprecated. More details on this format can be found in the [AWS User Guide](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access).\n\n### Why the Change?\n\nThe move to virtual-hosted–style URIs aligns with AWS's recommendation and future-proofing strategies. For an in-depth understanding of AWS's decision behind this transition, you can refer to their detailed post [here](https://aws.amazon.com/es/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story/).\n\n### Configuring Your Strapi Application\n\nIf you wish to continue using the plugin with Strapi 4.15.x versions or newer without changing your URL format, it's possible to specify your desired URL format directly in the plugin's configuration. Below is an example configuration highlighting the critical `baseUrl` property:\n\n```javascript\nupload: {\n  config: {\n    provider: 'aws-s3',\n    providerOptions: {\n      credentials: {\n        accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n        secretAccessKey: process.env.AWS_ACCESS_SECRET,\n      },\n      region: process.env.AWS_REGION,\n      baseUrl: `https://s3.${region}.amazonaws.com/${bucket}`, // This line sets the custom url format\n      params: {\n        ACL: process.env.AWS_ACL || 'public-read',\n        signedUrlExpires: process.env.AWS_SIGNED_URL_EXPIRES || 15 * 60,\n        Bucket: process.env.AWS_BUCKET,\n      },\n    },\n    actionOptions: {\n      upload: {},\n      uploadStream: {},\n      delete: {},\n    },\n  },\n}\n```\n\nThis configuration ensures compatibility with the updated AWS SDK while providing flexibility in URL format selection, catering to various user needs.\n","readmeFilename":"README.md"}