@aphexcms/storage-s3 14.0.0 → 15.0.0

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { StorageAdapter, StorageProvider, StorageConfig, UploadFileData, StorageFile } from '@aphexcms/cms-core/server';
1
+ import type { StorageAdapter, StorageProvider, StorageConfig, UploadFileData, StorageFile, StorageObjectMetadata, ListObjectsOptions, ListObjectsResult } from '@aphexcms/cms-core/server';
2
2
  export interface S3StorageConfig extends StorageConfig {
3
3
  options: {
4
4
  bucket: string;
@@ -21,9 +21,30 @@ export interface S3StorageConfig extends StorageConfig {
21
21
  * - Any other S3-compatible service
22
22
  *
23
23
  * Key design decisions:
24
- * - Storage keys include the bucket name (e.g., "my-bucket/filename.jpg")
24
+ * - Stored paths include the bucket name (e.g., "my-bucket/filename.jpg")
25
25
  * - Public URLs can use custom CDN/public URLs without the bucket prefix
26
26
  * - This separation allows S3 API to work correctly while serving public URLs cleanly
27
+ *
28
+ * ## Paths vs. keys
29
+ *
30
+ * `StorageFile.path` — what the CMS persists in `cms_assets.path` — is
31
+ * bucket-prefixed. The S3 *key* handed to s3mini is not: the client is
32
+ * constructed against a **bucket-scoped endpoint** (`{endpoint}/{bucket}`), so
33
+ * it addresses objects relative to the bucket.
34
+ *
35
+ * This matters beyond tidiness. s3mini derives its own `bucketName` from the
36
+ * endpoint (path segment first, then subdomain) and uses it to build the
37
+ * `x-amz-copy-source` header and to scope `listObjects`/`bucketExists`. Given an
38
+ * account-level endpoint like `https://<account>.r2.cloudflarestorage.com`, that
39
+ * derivation yields the *account hash*, so those operations silently address a
40
+ * bucket that does not exist — `listObjects` returns 501 NotImplemented,
41
+ * `copyObject` builds a bogus source, and `bucketExists` reports a perfectly
42
+ * healthy bucket as down. Scoping the endpoint to the bucket makes the
43
+ * derivation correct and those operations usable.
44
+ *
45
+ * Callers are unaffected: {@link toKey} strips the prefix on the way in and
46
+ * {@link toPath} restores it on the way out, so every path this adapter has ever
47
+ * returned keeps working.
27
48
  */
28
49
  export declare class S3StorageAdapter implements StorageAdapter {
29
50
  readonly name = "s3";
@@ -32,21 +53,98 @@ export declare class S3StorageAdapter implements StorageAdapter {
32
53
  private publicUrl;
33
54
  private config;
34
55
  constructor(config: S3StorageConfig);
56
+ /** See `StorageAdapter.setMaxFileSize` — the app's `upload.maxFileSize` wins. */
57
+ setMaxFileSize(bytes: number): void;
58
+ /**
59
+ * Append the bucket to the endpoint unless it is already scoped to it, so a
60
+ * user who configured a bucket-scoped endpoint themselves doesn't end up with
61
+ * `.../my-bucket/my-bucket/...`.
62
+ */
63
+ private static bucketScopedEndpoint;
64
+ /** Bucket-prefixed stored path -> bucket-relative S3 key. */
65
+ private toKey;
66
+ /** Bucket-relative S3 key -> the bucket-prefixed path the CMS stores. */
67
+ private toPath;
68
+ /**
69
+ * Where a logical key would land, for callers holding a key that never went
70
+ * through `store()` — a direct browser upload being the case that needs it.
71
+ *
72
+ * Applies `basePath` exactly as `store()` does. If it didn't, a direct upload
73
+ * would be signed for one location and read back from another, and an
74
+ * adapter configured with a prefix would appear to lose every file uploaded
75
+ * that way.
76
+ */
77
+ resolvePath(key: string): string;
78
+ /** The logical key as `store()` would write it. */
79
+ private withBasePath;
35
80
  private generateUniqueFilename;
36
81
  store(data: UploadFileData): Promise<StorageFile>;
37
82
  delete(path: string): Promise<boolean>;
38
83
  exists(path: string): Promise<boolean>;
84
+ /**
85
+ * Read an object back as a Buffer.
86
+ *
87
+ * Uses `getObjectArrayBuffer` rather than `getObject`: the latter decodes the
88
+ * response as text, which corrupts every binary payload the CMS stores. The
89
+ * image pipeline reads originals back out of storage to derive variants, so a
90
+ * byte-exact round-trip is a hard requirement, not a nicety.
91
+ */
92
+ getObject(path: string): Promise<Buffer>;
93
+ /**
94
+ * Stream an object rather than buffering it.
95
+ *
96
+ * This hands back the upstream response body untouched, so the bytes never
97
+ * accumulate in the process — strictly less work than `getObject`, which
98
+ * reads the whole object into an ArrayBuffer first. It's what lets the
99
+ * `/media` route serve a file larger than a serverless host's response-body
100
+ * cap.
101
+ */
102
+ getStream(path: string): Promise<ReadableStream<Uint8Array>>;
103
+ /**
104
+ * Ranged read, forwarded to S3 as a `Range` header so only the requested bytes
105
+ * cross the network — the point of implementing this at all.
106
+ *
107
+ * Two things about the client worth stating plainly:
108
+ *
109
+ * - `getObjectRaw`'s `rangeTo` is **exclusive** (it emits
110
+ * `bytes=${from}-${to - 1}`), while the port's `end` is inclusive, matching
111
+ * HTTP. Hence `end + 1`. Getting this wrong drops the final byte of every
112
+ * range, which corrupts media in a way that looks like a decoder bug.
113
+ * - `getObjectResponse` cannot be used here: it passes its options as *query*
114
+ * parameters rather than headers, and returns `null` for any status other
115
+ * than 200 — so a `206` would come back as "not found". `getObjectRaw`
116
+ * returns the raw `Response`.
117
+ */
118
+ getObjectRange(path: string, start: number, end: number): Promise<ReadableStream<Uint8Array>>;
119
+ listObjects(options?: ListObjectsOptions): Promise<ListObjectsResult>;
120
+ copyObject(sourcePath: string, destPath: string): Promise<boolean>;
121
+ getObjectMetadata(path: string): Promise<StorageObjectMetadata>;
39
122
  getUrl(path: string): string;
40
123
  getStorageInfo(): Promise<{
41
124
  totalSize: number;
42
125
  }>;
43
126
  isHealthy(): Promise<boolean>;
44
127
  /**
45
- * Returns the public URL for the asset. V1 assumes public buckets —
46
- * AWS Signature V4 signing is not yet implemented. If you need
47
- * private-bucket support, proxy requests through your server instead.
128
+ * Generate a time-limited download URL for a private object.
129
+ *
130
+ * Signed against the bucket-scoped endpoint, so the returned URL addresses the
131
+ * S3 API directly rather than `publicUrl`/CDN — a CDN hostname is not part of
132
+ * the signature and would reject it.
133
+ *
134
+ * @param expiresIn - Lifetime in seconds. S3 caps this at 7 days.
135
+ */
136
+ getSignedUrl(path: string, expiresIn?: number): Promise<string>;
137
+ /**
138
+ * Generate a time-limited upload URL, letting a browser PUT straight to the
139
+ * bucket instead of streaming the bytes through the CMS.
140
+ *
141
+ * `contentType` is signed when provided, which means the client MUST send that
142
+ * exact `Content-Type` header or the request is rejected.
143
+ *
144
+ * Not part of {@link StorageAdapter} — callers reach for it via the concrete
145
+ * adapter type.
48
146
  */
49
- getSignedUrl(path: string): Promise<string>;
147
+ getSignedUploadUrl(path: string, expiresIn?: number, contentType?: string): Promise<string>;
50
148
  }
51
149
  export declare class S3StorageProvider implements StorageProvider {
52
150
  name: string;
@@ -65,7 +163,9 @@ export declare class S3StorageProvider implements StorageProvider {
65
163
  * @param config.publicUrl - Public URL for file access (optional, uses endpoint if not provided)
66
164
  * @param config.region - AWS region (defaults to 'auto')
67
165
  * @param config.basePath - Optional path prefix for organizing files
68
- * @param config.maxFileSize - Maximum file size in bytes (default: 10MB)
166
+ * @param config.maxFileSize - Standalone default only, in bytes (10MB). Inside a
167
+ * CMS this is overwritten at config time by `upload.maxFileSize`, so set the
168
+ * limit there rather than here.
69
169
  *
70
170
  * @example Cloudflare R2
71
171
  * ```typescript
@@ -120,6 +220,7 @@ export declare function s3Storage(config: {
120
220
  publicUrl?: string;
121
221
  basePath?: string;
122
222
  baseUrl?: string;
223
+ /** Standalone default only — `upload.maxFileSize` overrides it inside a CMS. */
123
224
  maxFileSize?: number;
124
225
  }): {
125
226
  adapter: S3StorageAdapter;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACrD,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;;;EAiBA"}
package/dist/index.js CHANGED
@@ -11,9 +11,30 @@ import { S3mini } from 's3mini';
11
11
  * - Any other S3-compatible service
12
12
  *
13
13
  * Key design decisions:
14
- * - Storage keys include the bucket name (e.g., "my-bucket/filename.jpg")
14
+ * - Stored paths include the bucket name (e.g., "my-bucket/filename.jpg")
15
15
  * - Public URLs can use custom CDN/public URLs without the bucket prefix
16
16
  * - This separation allows S3 API to work correctly while serving public URLs cleanly
17
+ *
18
+ * ## Paths vs. keys
19
+ *
20
+ * `StorageFile.path` — what the CMS persists in `cms_assets.path` — is
21
+ * bucket-prefixed. The S3 *key* handed to s3mini is not: the client is
22
+ * constructed against a **bucket-scoped endpoint** (`{endpoint}/{bucket}`), so
23
+ * it addresses objects relative to the bucket.
24
+ *
25
+ * This matters beyond tidiness. s3mini derives its own `bucketName` from the
26
+ * endpoint (path segment first, then subdomain) and uses it to build the
27
+ * `x-amz-copy-source` header and to scope `listObjects`/`bucketExists`. Given an
28
+ * account-level endpoint like `https://<account>.r2.cloudflarestorage.com`, that
29
+ * derivation yields the *account hash*, so those operations silently address a
30
+ * bucket that does not exist — `listObjects` returns 501 NotImplemented,
31
+ * `copyObject` builds a bogus source, and `bucketExists` reports a perfectly
32
+ * healthy bucket as down. Scoping the endpoint to the bucket makes the
33
+ * derivation correct and those operations usable.
34
+ *
35
+ * Callers are unaffected: {@link toKey} strips the prefix on the way in and
36
+ * {@link toPath} restores it on the way out, so every path this adapter has ever
37
+ * returned keeps working.
17
38
  */
18
39
  export class S3StorageAdapter {
19
40
  name = 's3';
@@ -23,13 +44,13 @@ export class S3StorageAdapter {
23
44
  config;
24
45
  constructor(config) {
25
46
  const { bucket, endpoint, accessKeyId, secretAccessKey, region, publicUrl } = config.options;
47
+ this.bucket = bucket;
26
48
  this.client = new S3mini({
27
- endpoint,
49
+ endpoint: S3StorageAdapter.bucketScopedEndpoint(endpoint, bucket),
28
50
  accessKeyId,
29
51
  secretAccessKey,
30
52
  region: region || 'auto'
31
53
  });
32
- this.bucket = bucket;
33
54
  this.publicUrl = publicUrl || endpoint;
34
55
  this.config = {
35
56
  basePath: config.basePath ?? '',
@@ -37,6 +58,47 @@ export class S3StorageAdapter {
37
58
  maxFileSize: config.maxFileSize || 10 * 1024 * 1024 // 10MB default
38
59
  };
39
60
  }
61
+ /** See `StorageAdapter.setMaxFileSize` — the app's `upload.maxFileSize` wins. */
62
+ setMaxFileSize(bytes) {
63
+ if (Number.isFinite(bytes) && bytes > 0)
64
+ this.config.maxFileSize = bytes;
65
+ }
66
+ /**
67
+ * Append the bucket to the endpoint unless it is already scoped to it, so a
68
+ * user who configured a bucket-scoped endpoint themselves doesn't end up with
69
+ * `.../my-bucket/my-bucket/...`.
70
+ */
71
+ static bucketScopedEndpoint(endpoint, bucket) {
72
+ const trimmed = endpoint.replace(/\/+$/, '');
73
+ return trimmed.endsWith(`/${bucket}`) ? trimmed : `${trimmed}/${bucket}`;
74
+ }
75
+ /** Bucket-prefixed stored path -> bucket-relative S3 key. */
76
+ toKey(path) {
77
+ const withoutBucket = path.startsWith(`${this.bucket}/`)
78
+ ? path.slice(this.bucket.length + 1)
79
+ : path;
80
+ return withoutBucket.replace(/^\/+/, '');
81
+ }
82
+ /** Bucket-relative S3 key -> the bucket-prefixed path the CMS stores. */
83
+ toPath(key) {
84
+ return `${this.bucket}/${key.replace(/^\/+/, '')}`;
85
+ }
86
+ /**
87
+ * Where a logical key would land, for callers holding a key that never went
88
+ * through `store()` — a direct browser upload being the case that needs it.
89
+ *
90
+ * Applies `basePath` exactly as `store()` does. If it didn't, a direct upload
91
+ * would be signed for one location and read back from another, and an
92
+ * adapter configured with a prefix would appear to lose every file uploaded
93
+ * that way.
94
+ */
95
+ resolvePath(key) {
96
+ return this.toPath(this.withBasePath(key));
97
+ }
98
+ /** The logical key as `store()` would write it. */
99
+ withBasePath(key) {
100
+ return this.config.basePath ? `${this.config.basePath}/${key}` : key;
101
+ }
40
102
  generateUniqueFilename(originalFilename) {
41
103
  const lastDot = originalFilename.lastIndexOf('.');
42
104
  const name = lastDot > -1 ? originalFilename.substring(0, lastDot) : originalFilename;
@@ -47,28 +109,30 @@ export class S3StorageAdapter {
47
109
  if (data.size > this.config.maxFileSize) {
48
110
  throw new Error(`File too large: ${data.size} bytes`);
49
111
  }
50
- const filename = this.generateUniqueFilename(data.filename);
51
- // S3 operations require bucket in the key path
52
- const s3Key = this.config.basePath
53
- ? `${this.bucket}/${this.config.basePath}/${filename}`
54
- : `${this.bucket}/${filename}`;
55
- // Public URL path excludes bucket (public URL already points to bucket)
56
- const publicPath = this.config.basePath ? `${this.config.basePath}/${filename}` : filename;
112
+ // An explicit key is authoritative — the caller owns uniqueness and wants
113
+ // a predictable location (e.g. `{assetId}/original.png`, so variants can
114
+ // be written alongside it). Otherwise fall back to a generated name.
115
+ const filename = data.key ?? this.generateUniqueFilename(data.filename);
116
+ // Bucket-relative key; also the public URL path, since the public URL
117
+ // already points at the bucket. Shared with `resolvePath` so a direct
118
+ // upload is signed for exactly where `store()` would have put it.
119
+ const key = this.withBasePath(filename);
57
120
  // Ensure proper Buffer format for fetch API compatibility
58
121
  const buffer = Buffer.isBuffer(data.buffer) ? data.buffer : Buffer.from(data.buffer);
59
- await this.client.putObject(s3Key, buffer, data.mimeType);
122
+ await this.client.putObject(key, buffer, data.mimeType);
60
123
  return {
61
- path: s3Key,
62
- url: `${this.config.baseUrl}/${publicPath}`,
124
+ key,
125
+ path: this.toPath(key),
126
+ url: `${this.config.baseUrl}/${key}`,
63
127
  size: data.size
64
128
  };
65
129
  }
66
130
  async delete(path) {
67
- return await this.client.deleteObject(path);
131
+ return await this.client.deleteObject(this.toKey(path));
68
132
  }
69
133
  async exists(path) {
70
134
  try {
71
- const response = await this.client.objectExists(path);
135
+ const response = await this.client.objectExists(this.toKey(path));
72
136
  return Boolean(response?.valueOf?.() ?? response);
73
137
  }
74
138
  catch {
@@ -76,6 +140,106 @@ export class S3StorageAdapter {
76
140
  return false;
77
141
  }
78
142
  }
143
+ /**
144
+ * Read an object back as a Buffer.
145
+ *
146
+ * Uses `getObjectArrayBuffer` rather than `getObject`: the latter decodes the
147
+ * response as text, which corrupts every binary payload the CMS stores. The
148
+ * image pipeline reads originals back out of storage to derive variants, so a
149
+ * byte-exact round-trip is a hard requirement, not a nicety.
150
+ */
151
+ async getObject(path) {
152
+ const key = this.toKey(path);
153
+ const arrayBuffer = await this.client.getObjectArrayBuffer(key);
154
+ if (!arrayBuffer) {
155
+ throw new Error(`Object not found: ${path}`);
156
+ }
157
+ return Buffer.from(arrayBuffer);
158
+ }
159
+ /**
160
+ * Stream an object rather than buffering it.
161
+ *
162
+ * This hands back the upstream response body untouched, so the bytes never
163
+ * accumulate in the process — strictly less work than `getObject`, which
164
+ * reads the whole object into an ArrayBuffer first. It's what lets the
165
+ * `/media` route serve a file larger than a serverless host's response-body
166
+ * cap.
167
+ */
168
+ async getStream(path) {
169
+ const key = this.toKey(path);
170
+ const response = await this.client.getObjectResponse(key);
171
+ if (!response?.body) {
172
+ throw new Error(`Object not found: ${path}`);
173
+ }
174
+ return response.body;
175
+ }
176
+ /**
177
+ * Ranged read, forwarded to S3 as a `Range` header so only the requested bytes
178
+ * cross the network — the point of implementing this at all.
179
+ *
180
+ * Two things about the client worth stating plainly:
181
+ *
182
+ * - `getObjectRaw`'s `rangeTo` is **exclusive** (it emits
183
+ * `bytes=${from}-${to - 1}`), while the port's `end` is inclusive, matching
184
+ * HTTP. Hence `end + 1`. Getting this wrong drops the final byte of every
185
+ * range, which corrupts media in a way that looks like a decoder bug.
186
+ * - `getObjectResponse` cannot be used here: it passes its options as *query*
187
+ * parameters rather than headers, and returns `null` for any status other
188
+ * than 200 — so a `206` would come back as "not found". `getObjectRaw`
189
+ * returns the raw `Response`.
190
+ */
191
+ async getObjectRange(path, start, end) {
192
+ const key = this.toKey(path);
193
+ const response = await this.client.getObjectRaw(key, false, start, end + 1);
194
+ if (!response.ok || !response.body) {
195
+ void response.body?.cancel();
196
+ throw new Error(`Object not found: ${path}`);
197
+ }
198
+ return response.body;
199
+ }
200
+ async listObjects(options = {}) {
201
+ // Scope to basePath so an adapter configured with a prefix never lists
202
+ // objects outside it.
203
+ const prefixParts = [this.config.basePath, options.prefix].filter(Boolean);
204
+ const prefix = prefixParts.join('/');
205
+ // s3mini's first argument is named `delimiter`, but it is the request path
206
+ // rather than an S3 delimiter — it is never sent as a query parameter, so
207
+ // the listing is always flat (no CommonPrefixes) and '/' means "the bucket
208
+ // root". It rejects an empty string, so pass '/' explicitly.
209
+ const objects = await this.client.listObjects('/', prefix, options.maxKeys);
210
+ return {
211
+ objects: (objects ?? []).map((object) => ({
212
+ key: this.toPath(object.Key),
213
+ size: object.Size,
214
+ lastModified: object.LastModified,
215
+ etag: object.ETag
216
+ })),
217
+ // s3mini pages internally and resolves the full listing, so there is
218
+ // never a continuation token left for the caller to follow.
219
+ isTruncated: false
220
+ };
221
+ }
222
+ async copyObject(sourcePath, destPath) {
223
+ const result = await this.client.copyObject(this.toKey(sourcePath), this.toKey(destPath));
224
+ return Boolean(result?.etag);
225
+ }
226
+ async getObjectMetadata(path) {
227
+ const key = this.toKey(path);
228
+ // Two HEADs rather than one: s3mini exposes size and etag as separate
229
+ // calls and no combined head-object helper.
230
+ const [size, etag] = await Promise.all([
231
+ this.client.getContentLength(key),
232
+ this.client.getEtag(key)
233
+ ]);
234
+ return {
235
+ key: path,
236
+ size,
237
+ // s3mini's HEAD helpers don't surface Last-Modified. Callers that need
238
+ // it should use listObjects, which does.
239
+ lastModified: new Date(0),
240
+ etag: etag ?? undefined
241
+ };
242
+ }
79
243
  getUrl(path) {
80
244
  // Strip bucket prefix from stored path for public URLs
81
245
  // Example: "my-bucket/image.jpg" -> "image.jpg"
@@ -90,6 +254,10 @@ export class S3StorageAdapter {
90
254
  }
91
255
  async isHealthy() {
92
256
  try {
257
+ // Correct only because the client is scoped to the bucket (see the class
258
+ // docblock): `bucketExists` HEADs the endpoint root, which against an
259
+ // account-level endpoint probes the account rather than the bucket and
260
+ // reports a working bucket as down.
93
261
  return await this.client.bucketExists();
94
262
  }
95
263
  catch {
@@ -97,12 +265,29 @@ export class S3StorageAdapter {
97
265
  }
98
266
  }
99
267
  /**
100
- * Returns the public URL for the asset. V1 assumes public buckets —
101
- * AWS Signature V4 signing is not yet implemented. If you need
102
- * private-bucket support, proxy requests through your server instead.
268
+ * Generate a time-limited download URL for a private object.
269
+ *
270
+ * Signed against the bucket-scoped endpoint, so the returned URL addresses the
271
+ * S3 API directly rather than `publicUrl`/CDN — a CDN hostname is not part of
272
+ * the signature and would reject it.
273
+ *
274
+ * @param expiresIn - Lifetime in seconds. S3 caps this at 7 days.
275
+ */
276
+ async getSignedUrl(path, expiresIn = 3600) {
277
+ return await this.client.getPresignedUrl('GET', this.toKey(path), expiresIn);
278
+ }
279
+ /**
280
+ * Generate a time-limited upload URL, letting a browser PUT straight to the
281
+ * bucket instead of streaming the bytes through the CMS.
282
+ *
283
+ * `contentType` is signed when provided, which means the client MUST send that
284
+ * exact `Content-Type` header or the request is rejected.
285
+ *
286
+ * Not part of {@link StorageAdapter} — callers reach for it via the concrete
287
+ * adapter type.
103
288
  */
104
- async getSignedUrl(path) {
105
- return this.getUrl(path);
289
+ async getSignedUploadUrl(path, expiresIn = 300, contentType) {
290
+ return await this.client.getPresignedUrl('PUT', this.toKey(path), expiresIn, {}, contentType ? { 'Content-Type': contentType } : {});
106
291
  }
107
292
  }
108
293
  export class S3StorageProvider {
@@ -124,7 +309,9 @@ export class S3StorageProvider {
124
309
  * @param config.publicUrl - Public URL for file access (optional, uses endpoint if not provided)
125
310
  * @param config.region - AWS region (defaults to 'auto')
126
311
  * @param config.basePath - Optional path prefix for organizing files
127
- * @param config.maxFileSize - Maximum file size in bytes (default: 10MB)
312
+ * @param config.maxFileSize - Standalone default only, in bytes (10MB). Inside a
313
+ * CMS this is overwritten at config time by `upload.maxFileSize`, so set the
314
+ * limit there rather than here.
128
315
  *
129
316
  * @example Cloudflare R2
130
317
  * ```typescript
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAoBhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,gBAAgB;IACnB,IAAI,GAAG,IAAI,CAAC;IACb,MAAM,CAAS;IACf,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,MAAM,CAA2C;IAEzD,YAAY,MAAuB;QAClC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAE7F,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACxB,QAAQ;YACR,WAAW;YACX,eAAe;YACf,MAAM,EAAE,MAAM,IAAI,MAAM;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,QAAQ,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG;YACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;YAC/B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS;YACzC,WAAW,EAAE,MAA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AAG,IAAI,CAAC;IACZ,aAAa,CAAC,MAAqB;QAClC,OAAO,IAAI,gBAAgB,CAAC,MAAyB,CAAC,CAAC;IACxD,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,UAAU,SAAS,CAAC,MAWzB;IACA,OAAO;QACN,OAAO,EAAE,IAAI,gBAAgB,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;YAC/B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,QAAQ;YAC9D,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,OAAO,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC3B;SACD,CAAC;QACF,mBAAmB,EAAE,IAAI;KACzB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aphexcms/storage-s3",
3
- "version": "14.0.0",
3
+ "version": "15.0.0",
4
4
  "description": "S3-compatible storage adapter for Aphex CMS (AWS S3, Cloudflare R2, MinIO, etc.)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -26,15 +26,15 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "s3mini": "^0.7.0"
29
+ "s3mini": "^1.0.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@aphexcms/cms-core": "^9.2.0"
32
+ "@aphexcms/cms-core": "^10.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "tsup": "^8.5.1",
36
36
  "typescript": "^5.9.3",
37
- "@aphexcms/cms-core": "^9.2.0"
37
+ "@aphexcms/cms-core": "^10.0.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc",