@strapi/provider-upload-aws-s3 0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a → 0.0.0-next.fe88c7878fe2948cfdc68f4867329c1032a618b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -3
- package/README.md +60 -9
- package/dist/index.d.ts +27 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -4255
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -4253
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +10 -8
package/LICENSE
CHANGED
|
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
|
|
|
2
2
|
|
|
3
3
|
Portions of the Strapi software are licensed as follows:
|
|
4
4
|
|
|
5
|
-
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
|
|
6
|
+
|
|
7
|
+
Enterprise License
|
|
8
|
+
|
|
9
|
+
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
|
|
10
|
+
https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
|
|
11
|
+
represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
|
|
12
|
+
agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
|
|
13
|
+
Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
|
|
14
|
+
|
|
15
|
+
BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
|
|
16
|
+
IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
|
|
17
|
+
HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
|
|
18
|
+
THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
|
|
19
|
+
IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
|
|
6
20
|
|
|
7
21
|
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
22
|
|
|
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
|
|
|
18
32
|
The above copyright notice and this permission notice shall be included in all
|
|
19
33
|
copies or substantial portions of the Software.
|
|
20
34
|
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
36
|
+
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,
|
|
37
|
+
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.
|
package/README.md
CHANGED
|
@@ -49,8 +49,10 @@ module.exports = ({ env }) => ({
|
|
|
49
49
|
baseUrl: env('CDN_URL'),
|
|
50
50
|
rootPath: env('CDN_ROOT_PATH'),
|
|
51
51
|
s3Options: {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
credentials: {
|
|
53
|
+
accessKeyId: env('AWS_ACCESS_KEY_ID'),
|
|
54
|
+
secretAccessKey: env('AWS_ACCESS_SECRET'),
|
|
55
|
+
},
|
|
54
56
|
region: env('AWS_REGION'),
|
|
55
57
|
params: {
|
|
56
58
|
ACL: env('AWS_ACL', 'public-read'),
|
|
@@ -87,8 +89,10 @@ module.exports = ({ env }) => ({
|
|
|
87
89
|
config: {
|
|
88
90
|
provider: 'aws-s3',
|
|
89
91
|
providerOptions: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
credentials: {
|
|
93
|
+
accessKeyId: env('AWS_ACCESS_KEY_ID'),
|
|
94
|
+
secretAccessKey: env('AWS_ACCESS_SECRET'),
|
|
95
|
+
},
|
|
92
96
|
region: env('AWS_REGION'),
|
|
93
97
|
params: {
|
|
94
98
|
ACL: 'private', // <== set ACL to private
|
|
@@ -109,7 +113,7 @@ module.exports = ({ env }) => ({
|
|
|
109
113
|
|
|
110
114
|
#### Configuration for S3 compatible services
|
|
111
115
|
|
|
112
|
-
This plugin may work with S3 compatible services by using the `endpoint
|
|
116
|
+
This plugin may work with S3 compatible services by using the `endpoint`. Scaleway example:
|
|
113
117
|
`./config/plugins.js`
|
|
114
118
|
|
|
115
119
|
```js
|
|
@@ -119,9 +123,12 @@ module.exports = ({ env }) => ({
|
|
|
119
123
|
config: {
|
|
120
124
|
provider: 'aws-s3',
|
|
121
125
|
providerOptions: {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
credentials: {
|
|
127
|
+
accessKeyId: env('SCALEWAY_ACCESS_KEY_ID'),
|
|
128
|
+
secretAccessKey: env('SCALEWAY_ACCESS_SECRET'),
|
|
129
|
+
},
|
|
130
|
+
region: env('SCALEWAY_REGION'), // e.g "fr-par"
|
|
131
|
+
endpoint: env('SCALEWAY_ENDPOINT'), // e.g. "https://s3.fr-par.scw.cloud"
|
|
125
132
|
params: {
|
|
126
133
|
Bucket: env('SCALEWAY_BUCKET'),
|
|
127
134
|
},
|
|
@@ -171,7 +178,7 @@ module.exports = [
|
|
|
171
178
|
];
|
|
172
179
|
```
|
|
173
180
|
|
|
174
|
-
If you use dots in your bucket name, the url of the
|
|
181
|
+
If 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.
|
|
175
182
|
|
|
176
183
|
## Bucket CORS Configuration
|
|
177
184
|
|
|
@@ -202,3 +209,47 @@ These are the minimum amount of permissions needed for this provider to work.
|
|
|
202
209
|
"s3:PutObjectAcl"
|
|
203
210
|
],
|
|
204
211
|
```
|
|
212
|
+
|
|
213
|
+
## Update to AWS SDK V3 and URL Format Change
|
|
214
|
+
|
|
215
|
+
In 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.
|
|
216
|
+
|
|
217
|
+
### Understanding the New URL Format
|
|
218
|
+
|
|
219
|
+
AWS 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).
|
|
220
|
+
|
|
221
|
+
### Why the Change?
|
|
222
|
+
|
|
223
|
+
The 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/).
|
|
224
|
+
|
|
225
|
+
### Configuring Your Strapi Application
|
|
226
|
+
|
|
227
|
+
If 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:
|
|
228
|
+
|
|
229
|
+
```javascript
|
|
230
|
+
upload: {
|
|
231
|
+
config: {
|
|
232
|
+
provider: 'aws-s3',
|
|
233
|
+
providerOptions: {
|
|
234
|
+
credentials: {
|
|
235
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
236
|
+
secretAccessKey: process.env.AWS_ACCESS_SECRET,
|
|
237
|
+
},
|
|
238
|
+
region: process.env.AWS_REGION,
|
|
239
|
+
baseUrl: `https://s3.${region}.amazonaws.com/${bucket}`, // This line sets the custom url format
|
|
240
|
+
params: {
|
|
241
|
+
ACL: process.env.AWS_ACL || 'public-read',
|
|
242
|
+
signedUrlExpires: process.env.AWS_SIGNED_URL_EXPIRES || 15 * 60,
|
|
243
|
+
Bucket: process.env.AWS_BUCKET,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
actionOptions: {
|
|
247
|
+
upload: {},
|
|
248
|
+
uploadStream: {},
|
|
249
|
+
delete: {},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
This configuration ensures compatibility with the updated AWS SDK while providing flexibility in URL format selection, catering to various user needs.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { ReadStream } from 'node:fs';
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { DeleteObjectCommandOutput, CompleteMultipartUploadCommandOutput, AbortMultipartUploadCommandOutput, S3ClientConfig, ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
5
|
+
import type { AwsCredentialIdentity } from '@aws-sdk/types';
|
|
6
|
+
export interface File {
|
|
6
7
|
name: string;
|
|
7
8
|
alternativeText?: string;
|
|
8
9
|
caption?: string;
|
|
@@ -13,6 +14,7 @@ interface File {
|
|
|
13
14
|
ext?: string;
|
|
14
15
|
mime: string;
|
|
15
16
|
size: number;
|
|
17
|
+
sizeInBytes: number;
|
|
16
18
|
url: string;
|
|
17
19
|
previewUrl?: string;
|
|
18
20
|
path?: string;
|
|
@@ -21,26 +23,38 @@ interface File {
|
|
|
21
23
|
stream?: ReadStream;
|
|
22
24
|
buffer?: Buffer;
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
export type UploadCommandOutput = (CompleteMultipartUploadCommandOutput | AbortMultipartUploadCommandOutput) & {
|
|
27
|
+
Location: string;
|
|
28
|
+
};
|
|
29
|
+
export interface AWSParams {
|
|
30
|
+
Bucket: string;
|
|
31
|
+
ACL?: ObjectCannedACL;
|
|
32
|
+
signedUrlExpires?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface DefaultOptions extends S3ClientConfig {
|
|
35
|
+
accessKeyId?: AwsCredentialIdentity['accessKeyId'];
|
|
36
|
+
secretAccessKey?: AwsCredentialIdentity['secretAccessKey'];
|
|
37
|
+
credentials?: AwsCredentialIdentity;
|
|
38
|
+
params?: AWSParams;
|
|
39
|
+
[k: string]: any;
|
|
40
|
+
}
|
|
41
|
+
export type InitOptions = (DefaultOptions | {
|
|
42
|
+
s3Options: DefaultOptions;
|
|
43
|
+
}) & {
|
|
25
44
|
baseUrl?: string;
|
|
26
45
|
rootPath?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Bucket: string;
|
|
30
|
-
ACL?: string;
|
|
31
|
-
signedUrlExpires?: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}
|
|
46
|
+
[k: string]: any;
|
|
47
|
+
};
|
|
35
48
|
declare const _default: {
|
|
36
49
|
init({ baseUrl, rootPath, s3Options, ...legacyS3Options }: InitOptions): {
|
|
37
50
|
isPrivate(): boolean;
|
|
38
|
-
getSignedUrl(file: File): Promise<{
|
|
51
|
+
getSignedUrl(file: File, customParams: any): Promise<{
|
|
39
52
|
url: string;
|
|
40
53
|
}>;
|
|
41
54
|
uploadStream(file: File, customParams?: {}): Promise<void>;
|
|
42
55
|
upload(file: File, customParams?: {}): Promise<void>;
|
|
43
|
-
delete(file: File, customParams?: {}): Promise<
|
|
56
|
+
delete(file: File, customParams?: {}): Promise<DeleteObjectCommandOutput>;
|
|
44
57
|
};
|
|
45
58
|
};
|
|
46
59
|
export default _default;
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAIL,yBAAyB,EAEzB,oCAAoC,EACpC,iCAAiC,EACjC,cAAc,EACd,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAK5D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAA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