Merge pull request #14043 from strapi/dep/rackspace

Deprecate Rackspace upload provider
This commit is contained in:
Alexandre BODIN 2022-08-10 11:34:16 +02:00 committed by GitHub
commit f5b0ca09fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 351 deletions

View File

@ -1,16 +0,0 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{package.json,*.yml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false

View File

@ -1,31 +0,0 @@
# Ignore docs files
_gh_pages
_site
_build
.sass-cache
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.gz
*.vi
*~
# OS or Editor folders
.DS_Store
._*
Thumbs.db
.cache
.project
.settings
.tmproj
.idea
*.esproj
*.sublime-project
*.sublime-workspace

View File

@ -1,100 +0,0 @@
############################
# OS X
############################
.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*
############################
# Linux
############################
*~
############################
# Windows
############################
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
############################
# Packages
############################
*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid
############################
# Logs and databases
############################
.tmp
*.log
*.sql
*.sqlite
############################
# Misc.
############################
*#
ssl
.editorconfig
.gitattributes
.idea
nbproject
############################
# Node.js
############################
lib-cov
lcov.info
pids
logs
results
build
node_modules
.node_history
############################
# Tests
############################
test
tests
__tests__
jest.config.js

View File

@ -1,22 +0,0 @@
Copyright (c) 2015-present Strapi Solutions SAS
Portions of the Strapi software are licensed as follows:
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
MIT Expat License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,84 +0,0 @@
# @strapi/provider-upload-rackspace
## Resources
- [LICENSE](LICENSE)
## Links
- [Strapi website](https://strapi.io/)
- [Strapi documentation](https://docs.strapi.io)
- [Strapi community on Discord](https://discord.strapi.io)
- [Strapi news on Twitter](https://twitter.com/strapijs)
## Installation
```bash
# using yarn
yarn add @strapi/provider-upload-rackspace
# using npm
npm install @strapi/provider-upload-rackspace --save
```
## Configuration
- `provider` defines the name of the provider
- `providerOptions` is passed down during the construction of the provider. (ex: `createClient(config)`). [Complete list of options](https://github.com/pkgcloud/pkgcloud/blob/master/docs/providers/rackspace/README.md). The implementation is based on the package `pkgcloud`. [Documentation](https://github.com/pkgcloud/pkgcloud#storage)
- `actionOptions` is passed directly to each method respectively allowing for custom options. You can find the complete list of [upload/ uploadStream options](https://github.com/pkgcloud/pkgcloud#upload-a-file) and [delete options](https://github.com/pkgcloud/pkgcloud/blob/master/docs/providers/rackspace/storage.md#clientremovefilecontainer-file-functionerr-result--)
See 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).
### Provider Configuration
`./config/plugins.js`
```js
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'rackspace',
providerOptions: {
username: env('RACKSPACE_USERNAME'),
apiKey: env('RACKSPACE_KEY'),
region: env('RACKSPACE_REGION'),
container: env('RACKSPACE_CONTAINER'),
},
actionOptions: {
upload: {},
uploadStream: {},
delete: {},
},
},
},
// ...
});
```
### 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](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.html#loading-order) documentation.
`./config/middlewares.js`
```js
module.exports = [
// ...
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': ["'self'", 'data:', 'blob:', 'storage.clouddrive.com'],
'media-src': ["'self'", 'data:', 'blob:', 'storage.clouddrive.com'],
upgradeInsecureRequests: null,
},
},
},
},
// ...
];
```

View File

@ -1,63 +0,0 @@
'use strict';
/**
* Module dependencies
*/
// Public node modules.
const pkgcloud = require('pkgcloud');
const streamifier = require('streamifier');
module.exports = {
init(config) {
const options = { container: config.container };
const client = pkgcloud.storage.createClient({
provider: 'rackspace',
...config,
});
const remoteURL = () =>
new Promise((resolve, reject) => {
return client.getContainer(config.container, (err, res) => {
if (err && !res) return reject(err);
return resolve(res);
});
});
return {
upload(file) {
const readStream = streamifier.createReadStream(file.buffer);
const writeStream = client.upload({
...options,
remote: file.hash,
contentType: file.mime,
});
return new Promise((resolve, reject) => {
readStream.pipe(writeStream);
writeStream.on('error', error => error && reject(error));
writeStream.on('success', result => {
remoteURL()
.then(data => {
resolve(
Object.assign(file, {
mime: result.contentType,
url: `${data.cdnSslUri}/${result.name}`,
})
);
})
.catch(err => console.error(err) && reject(err));
});
});
},
delete(file) {
return new Promise((resolve, reject) => {
client.removeFile(config.container, file.hash, error => {
if (error) return reject(error);
return resolve();
});
});
},
};
},
};

View File

@ -1,35 +0,0 @@
{
"name": "@strapi/provider-upload-rackspace",
"version": "4.3.2",
"description": "Rackspace provider for strapi upload",
"repository": {
"type": "git",
"url": "https://github.com/strapi/strapi.git",
"directory": "packages/providers/upload-rackspace"
},
"keywords": [],
"license": "SEE LICENSE IN LICENSE",
"author": {
"name": "Pongstr Ordillo",
"url": "https://github.com/pongstr"
},
"maintainers": [
{
"name": "Strapi Solutions SAS",
"email": "hi@strapi.io",
"url": "https://strapi.io"
}
],
"main": "./lib",
"scripts": {
"test": "echo \"no tests yet\""
},
"dependencies": {
"pkgcloud": "2.2.0",
"streamifier": "0.1.1"
},
"engines": {
"node": ">=14.19.1 <=16.x.x",
"npm": ">=6.0.0"
}
}