npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-provider-upload-s3-plus

v0.1.1

Published

Strapi upload provider using asw-s3 allowing the use of ACL and folders onto S3 providers that are aws-s3 compatible

Downloads

14

Readme

Strapi Upload Provider - S3 Plus

A simple upload provider using aws-s3 allowing you to specify the ACL and base path (folder) on any aws-s3 compatible S3 service. This is very similar to how strapi-provider-upload-aws-s3 works but makes setting ACL and a base folder easier.

Installation

Using NPM

npm install --save strapi-provider-upload-s3-plus

Using Yarn

yarn add strapi-provider-upload-s3-plus

Setup

Enable the provider using Strapi's plugin config config/plugins.js

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus"
    }
})

Configuration

Configure the provider in Strapi's plugin config config/plugins.js

By default the apiVersion is "2006-03-01", you can change this using the apiVersion property in providerOptions.

The provider configuration defined in providerOptions is passed directly to the aws-sdk, see the full configuration options.

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus",
        providerOptions: {
            // AWS-SDK S3 provider options
        }
    }
})

e.g.

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus",
        providerOptions: {
            accessKeyId: 'abcdefghijklmnopqrstuvwxyz123',
            secretAccessKey: 'abcdefghijklmnopqrstuvwxyz123',
            region: 'us-east-1',
            params: {
                Bucket: 'mybucket',
                ACL: 'public-read',
                folder: 'myapp/images',
            }
        }
    }
})

It's recommended to use environment variables from the host for sensitive configuration details and map the environment variables to the plugin configuration:

Example config/plugins.js using host environment variables:

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus",
        providerOptions: {
            accessKeyId: env('AWS_ACCESS_KEY_ID'),
            secretAccessKey: env('AWS_ACCESS_SECRET'),
            region: env('AWS_REGION'),
            params: {
                Bucket: env('AWS_BUCKET'),
                ACL: env('AWS_ACL'),
                folder: env('AWS_FOLDER'),
            }
        }
    }
})

Other S3 providers

There is plenty of documentation on configuring aws-sdk S3 for AWS S3 Services, below is an example using DigitalOcean Spaces. Configure the endpoint property directly.

Example Digital Ocean Spaces configuration:

config/plugin.js:

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus",
        providerOptions: {
            accessKeyId: env('AWS_ACCESS_KEY_ID'),
            secretAccessKey: env('AWS_ACCESS_SECRET'),
            endpoint: env('AWS_ENDPOINT'),
            params: {
                Bucket: env('AWS_BUCKET'),
                ACL: env('AWS_ACL'),
                folder: env('AWS_FOLDER'),
            }
        }
    }
})

Host environment variables:

AWS_ACCESS_KEY_ID=abcdefghijklmnopqrstuvwxyz123
AWS_ACCESS_SECRET=abcdefghijklmnopqrstuvwxyz123
AWS_ENDPOINT=https://sgp1.digitaloceanspaces.com
AWS_BUCKET=mybucket
AWS_ACL=public-read
AWS_FOLDER=myfolder/uploads

Example using localstack aws simulated services.

config/plugin.js:

module.exports = ({env}) => ({
    upload: {
        provider: "s3-plus",
        providerOptions: {
            accessKeyId: '1234567890',
            secretAccessKey: 'abcdefghijklmnopqrstuvwxyz123',
            endpoint: 'http://region.localstack:4572',
            region: 'region',
            params: {
                Bucket: 'bucket',
                ACL: 'public-read',
                folder: 'strapi/uploads',
            },
            s3ForcePathStyle: true, //needed for localstack s3 to work correctly
        }
    }
})