strapi-provider-upload-linode
Version:
Linode S3 object storage provider for Strapi upload plugin
116 lines (93 loc) • 3.25 kB
Markdown
# Strapi Upload Provider for Linode Object Storage
## Parameters
- **key** : [storage access key]
- **secret** : [storage access secret]
- **endpoint** : Base URL of the space (e.g. `ap-south-1.linodeobjects.com`)
- **space** : Name of the s3 bucketName.
- **directory** : Name of the sub-directory you want to store your files in. (Optionnal - e.g. `/example`)
- **cdn** : CDN Endpoint - URL of the cdn of the space (Optionnal - e.g. `cdn.example.com`)
# How to use
## 1. Install this package
```bash
npm i strapi-provider-upload-linode
```
```bash
yarn add strapi-provider-upload-linode
```
```bash
pnpm add strapi-provider-upload-linode
```
### 2. Create `.env` and add provide Linode config.
```bash
LI_OBJECT_S3_ACCESS_KEY=
LI_OBJECT_S3_SECRET_KEY=
LI_OBJECT_S3_ENDPOINT=
LI_OBJECT_S3_BUCKET_NAME=
LI_OBJECT_S3_DIRECTORY=
LI_OBJECT_S3_CDN=
```
Parameter `LI_OBJECT_S3_DIRECTORY` and `LI_OBJECT_S3_CDN` is optional and you can ommit them both in `.env` and `settings`.
## 3. Create or update config in `./config/plugins.js` with content
```js
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: "strapi-provider-upload-linode",
providerOptions: {
key: env("LI_OBJECT_S3_ACCESS_KEY"),
secret: env("LI_OBJECT_S3_SECRET_KEY"),
endpoint: env("LI_OBJECT_S3_ENDPOINT"),
space: env("LI_OBJECT_S3_BUCKET_NAME"),
directory: env("LI_OBJECT_S3_DIRECTORY"), // optional
cdn: env("LI_OBJECT_S3_CDN"), // optional
},
},
},
// ...
});
```
## 4. Security Middleware Configuration
Due 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 documentation.
`./config/middlewares.js`
```js
module.exports = [
// ...
{
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "https:"],
"img-src": [
"'self'",
"data:",
"blob:",
"market-assets.strapi.io",
"yourBucketName.yourRegion.linodeobjects.com", // change here
],
"media-src": [
"'self'",
"data:",
"blob:",
"market-assets.strapi.io",
"yourBucketName.yourRegion.linodeobjects.com", // change here
],
upgradeInsecureRequests: null,
},
},
},
},
// ...
];
```
## Resources
- [MIT License](LICENSE.md)
## Links
- [Strapi website](http://strapi.io/)
- [Strapi community on Slack](http://slack.strapi.io)
- [Strapi news on Twitter](https://twitter.com/strapijs)
- [Strapi docs about upload](https://strapi.io/documentation/3.0.0-beta.x/plugins/upload.html#configuration)
## Contributors
<a href="https://github.com/elias-emon"><img src="https://avatars.githubusercontent.com/u/141176723?v=4" title="Elias Emon" width="80" height="80"></a>