@strapi/provider-upload-aws-s3 0.0.0-next.b42bb21c873e617eed0eb36b0a4872b7c5bd6b0c → 0.0.0-next.b6d552f6e63dec5627cb8611ab2adcb8244359be

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/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
- accessKeyId: env('AWS_ACCESS_KEY_ID'),
53
- secretAccessKey: env('AWS_ACCESS_SECRET'),
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
- accessKeyId: env('AWS_ACCESS_KEY_ID'),
91
- secretAccessKey: env('AWS_ACCESS_SECRET'),
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
@@ -119,8 +123,10 @@ module.exports = ({ env }) => ({
119
123
  config: {
120
124
  provider: 'aws-s3',
121
125
  providerOptions: {
122
- accessKeyId: env('SCALEWAY_ACCESS_KEY_ID'),
123
- secretAccessKey: env('SCALEWAY_ACCESS_SECRET'),
126
+ credentials: {
127
+ accessKeyId: env('SCALEWAY_ACCESS_KEY_ID'),
128
+ secretAccessKey: env('SCALEWAY_ACCESS_SECRET'),
129
+ },
124
130
  endpoint: env('SCALEWAY_ENDPOINT'), // e.g. "s3.fr-par.scw.cloud"
125
131
  params: {
126
132
  Bucket: env('SCALEWAY_BUCKET'),
@@ -171,7 +177,7 @@ module.exports = [
171
177
  ];
172
178
  ```
173
179
 
174
- If you use dots in your bucket name, the url of the ressource is in directory style (`s3.yourRegion.amazonaws.com/your.bucket.name/image.jpg`) instead of `yourBucketName.s3.yourRegion.amazonaws.com/image.jpg`. Then only add `s3.yourRegion.amazonaws.com` to img-src and media-src directives.
180
+ If you use dots in your bucket name, 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
181
 
176
182
  ## Bucket CORS Configuration
177
183
 
@@ -202,3 +208,47 @@ These are the minimum amount of permissions needed for this provider to work.
202
208
  "s3:PutObjectAcl"
203
209
  ],
204
210
  ```
211
+
212
+ ## Update to AWS SDK V3 and URL Format Change
213
+
214
+ 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.
215
+
216
+ ### Understanding the New URL Format
217
+
218
+ 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).
219
+
220
+ ### Why the Change?
221
+
222
+ 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/).
223
+
224
+ ### Configuring Your Strapi Application
225
+
226
+ 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:
227
+
228
+ ```javascript
229
+ upload: {
230
+ config: {
231
+ provider: 'aws-s3',
232
+ providerOptions: {
233
+ credentials: {
234
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
235
+ secretAccessKey: process.env.AWS_ACCESS_SECRET,
236
+ },
237
+ region: process.env.AWS_REGION,
238
+ baseUrl: `https://s3.${region}.amazonaws.com/${bucket}`, // This line sets the custom url format
239
+ params: {
240
+ ACL: process.env.AWS_ACL || 'public-read',
241
+ signedUrlExpires: process.env.AWS_SIGNED_URL_EXPIRES || 15 * 60,
242
+ Bucket: process.env.AWS_BUCKET,
243
+ },
244
+ },
245
+ actionOptions: {
246
+ upload: {},
247
+ uploadStream: {},
248
+ delete: {},
249
+ },
250
+ },
251
+ }
252
+ ```
253
+
254
+ 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 AWS from 'aws-sdk';
5
- interface File {
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
- interface InitOptions extends Partial<AWS.S3.ClientConfiguration> {
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
- s3Options: AWS.S3.ClientConfiguration & {
28
- params: {
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<void>;
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,EA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