Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit f1a6ad1

Browse files
authored
Update README.md
1 parent c9844f2 commit f1a6ad1

File tree

1 file changed

+2
-197
lines changed

1 file changed

+2
-197
lines changed

README.md

Lines changed: 2 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,3 @@
1-
# Payload Cloud Storage Plugin
1+
# This repo has moved!
22

3-
This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store all uploaded media in third-party permanent storage.
4-
5-
#### Requirements
6-
7-
- Payload version `1.0.19` or higher is required
8-
9-
## Installation
10-
11-
`yarn add @payloadcms/plugin-cloud-storage` or `npm install @payloadcms/plugin-cloud-storage`
12-
13-
## Usage
14-
15-
Add this package into your dependencies executing this code in your command line:
16-
17-
`yarn add @payloadcms/plugin-cloud-storage`
18-
19-
Now install this plugin within your Payload as follows:
20-
21-
```ts
22-
import { buildConfig } from 'payload/config';
23-
import path from 'path';
24-
import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
25-
26-
export default buildConfig({
27-
plugins: [
28-
cloudStorage({
29-
collections: {
30-
'my-collection-slug': {
31-
adapter: theAdapterToUse, // see docs for the adapter you want to use
32-
},
33-
},
34-
}),
35-
],
36-
// The rest of your config goes here
37-
});
38-
```
39-
40-
### Conditionally Enabling/Disabling
41-
42-
The proper way to conditionally enable/disable this plugin is to use the `enabled` property.
43-
44-
```ts
45-
cloudStorage({
46-
enabled: process.env.MY_CONDITION === 'true',
47-
collections: {
48-
'my-collection-slug': {
49-
adapter: theAdapterToUse, // see docs for the adapter you want to use
50-
},
51-
},
52-
}),
53-
```
54-
55-
If the code is included *in any way in your config* but conditionally disabled in another fashion, you may run into issues such as `Webpack Build Error: Can't Resolve 'fs' and 'stream'` or similar because the plugin must be run at all times in order to properly extend the webpack config.
56-
57-
## Features
58-
59-
**Adapter-based Implementation**
60-
61-
This plugin supports the following adapters:
62-
63-
- [Azure Blob Storage](#azure-blob-storage-adapter)
64-
- [AWS S3-style Storage](#s3-adapter)
65-
- [Google Cloud Storage](#gcs-adapter)
66-
67-
However, you can create your own adapter for any third-party service you would like to use.
68-
69-
All adapters are implemented `dev` directory's [Payload Config](https://github.com/payloadcms/plugin-cloud-storage/blob/master/dev/src/payload.config.ts). See this file for examples.
70-
71-
## Plugin options
72-
73-
This plugin is configurable to work across many different Payload collections. A `*` denotes that the property is required.
74-
75-
| Option | Type | Description |
76-
|-------------------------|-----------------------------------------| ----------- |
77-
| `collections` * | Record<string, [CollectionOptions](https://github.com/payloadcms/plugin-cloud-storage/blob/c4a492a62abc2f21b4cd6a7c97778acd8e831212/src/types.ts#L48)> | Object with keys set to the slug of collections you want to enable the plugin for, and values set to collection-specific options. |
78-
| `enabled` | | `boolean` to conditionally enable/disable plugin. Default: true. |
79-
80-
**Collection-specific options:**
81-
82-
| Option | Type | Description |
83-
|-------------------------------|----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
84-
| `adapter` * | [Adapter](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L51) | Pass in the adapter that you'd like to use for this collection. You can also set this field to `null` for local development if you'd like to bypass cloud storage in certain scenarios and use local storage. |
85-
| `disableLocalStorage` | `boolean` | Choose to disable local storage on this collection. Defaults to `true`. |
86-
| `disablePayloadAccessControl` | `true` | Set to `true` to disable Payload's access control. [More](#payload-access-control) |
87-
| `prefix` | `string` | Set to `media/images` to upload files inside `media/images` folder in the bucket. |
88-
| `generateFileURL` | [GenerateFileURL](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L53) | Override the generated file URL with one that you create. |
89-
90-
### Azure Blob Storage Adapter
91-
92-
To use the Azure Blob Storage adapter, you need to have `@azure/storage-blob` installed in your project dependencies. To do so, run `yarn add @azure/storage-blob`.
93-
94-
From there, create the adapter, passing in all of its required properties:
95-
96-
```js
97-
import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage/azure';
98-
99-
const adapter = azureBlobStorageAdapter({
100-
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
101-
containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
102-
allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
103-
baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
104-
})
105-
106-
// Now you can pass this adapter to the plugin
107-
```
108-
109-
### S3 Adapter
110-
111-
To use the S3 adapter, some peer dependencies need to be installed:
112-
113-
`yarn add @aws-sdk/client-s3 @aws-sdk/lib-storage aws-crt`.
114-
115-
From there, create the adapter, passing in all of its required properties:
116-
117-
```js
118-
import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
119-
120-
const adapter = s3Adapter({
121-
config: {
122-
credentials: {
123-
accessKeyId: process.env.S3_ACCESS_KEY_ID,
124-
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
125-
},
126-
region: process.env.S3_REGION,
127-
// ... Other S3 configuration
128-
},
129-
bucket: process.env.S3_BUCKET,
130-
})
131-
132-
// Now you can pass this adapter to the plugin
133-
```
134-
Note that the credentials option does not have to be used when you are using PayloadCMS on an EC2 instance that has been configured with an IAM Role with necessary permissions.
135-
136-
Other S3 Client configuration is documented [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html).
137-
138-
Any upload over 50MB will automatically be uploaded using S3's multi-part upload.
139-
140-
#### Other S3-Compatible Storage
141-
142-
If you're running an S3-compatible object storage such as MinIO or Digital Ocean Spaces, you'll have to set the `endpoint` appropriately for the provider.
143-
144-
```js
145-
import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3';
146-
147-
const adapter = s3Adapter({
148-
config: {
149-
endpoint: process.env.S3_ENDPOINT, // Configure for your provider
150-
// ...
151-
},
152-
// ...
153-
})
154-
```
155-
156-
### GCS Adapter
157-
158-
To use the GCS adapter, you need to have `@google-cloud/storage` installed in your project dependencies. To do so, run `yarn add @google-cloud/storage`.
159-
160-
From there, create the adapter, passing in all of its required properties:
161-
162-
```js
163-
import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs';
164-
165-
const adapter = gcsAdapter({
166-
options: {
167-
// you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
168-
keyFilename: './gcs-credentials.json',
169-
//OR
170-
credentials: JSON.parse(process.env.GCS_CREDENTIALS || "{}") // this env variable will have stringify version of your credentials.json file
171-
},
172-
bucket: process.env.GCS_BUCKET,
173-
})
174-
175-
// Now you can pass this adapter to the plugin
176-
```
177-
178-
### Payload Access Control
179-
180-
Payload ships with access control that runs *even on statically served files*. The same `read` access control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
181-
182-
To preserve this feature, by default, this plugin *keeps all file URLs exactly the same*. Your file URLs won't be updated to point directly to your cloud storage source, as in that case, Payload's access control will be completely bypassed and you would need public readability on your cloud-hosted files.
183-
184-
Instead, all uploads will still be reached from the default `/collectionSlug/staticURL/filename` path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place.
185-
186-
If this does not apply to you (your upload collection has `read: () => true` or similar) you can disable this functionality by setting `disablePayloadAccessControl` to `true`. When this setting is in place, this plugin will update your file URLs to point directly to your cloud host.
187-
188-
## Local development
189-
190-
For instructions regarding how to develop with this plugin locally, [click here](https://github.com/payloadcms/plugin-cloud-storage/blob/master/docs/local-dev.md).
191-
192-
## Questions
193-
194-
Please contact [Payload](mailto:[email protected]) with any questions about using this plugin.
195-
196-
## Credit
197-
198-
This plugin was created with significant help, and code, from [Alex Bechmann](https://github.com/alexbechmann) and [Richard VanBergen](https://github.com/richardvanbergen). Thank you!!
3+
This repo has been merged into the [Packages Directory](https://github.com/payloadcms/payload/tree/main/packages) of the [Payload Monorepo](https://github.com/payloadcms/payload). Please refer to the new location of the [SEO Plugin](https://github.com/payloadcms/payload/tree/main/packages/plugin-cloud-storage) for all future updates, issues, and pull requests.

0 commit comments

Comments
 (0)