@allegria/aws-file-manager 1.0.1 → 1.0.3
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/cjs/aws-file-manager.d.ts +318 -0
- package/dist/cjs/aws-file-manager.js +426 -0
- package/dist/cjs/aws-file-manager.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/lib/aws-file-manager.d.ts +1 -1
- package/dist/lib/aws-file-manager.js +5 -1
- package/dist/lib/aws-file-manager.js.map +1 -1
- package/package.json +27 -9
- package/dist/examples/01-setup.d.ts +0 -14
- package/dist/examples/01-setup.js +0 -42
- package/dist/examples/01-setup.js.map +0 -1
- package/dist/examples/02-upload-multer.d.ts +0 -13
- package/dist/examples/02-upload-multer.js +0 -63
- package/dist/examples/02-upload-multer.js.map +0 -1
- package/dist/examples/03-upload-web.d.ts +0 -12
- package/dist/examples/03-upload-web.js +0 -38
- package/dist/examples/03-upload-web.js.map +0 -1
- package/dist/examples/04-signed-urls.d.ts +0 -12
- package/dist/examples/04-signed-urls.js +0 -48
- package/dist/examples/04-signed-urls.js.map +0 -1
- package/dist/examples/05-download.d.ts +0 -14
- package/dist/examples/05-download.js +0 -53
- package/dist/examples/05-download.js.map +0 -1
- package/dist/examples/06-delete.d.ts +0 -17
- package/dist/examples/06-delete.js +0 -44
- package/dist/examples/06-delete.js.map +0 -1
- package/dist/examples/07-copy.d.ts +0 -14
- package/dist/examples/07-copy.js +0 -35
- package/dist/examples/07-copy.js.map +0 -1
- package/dist/examples/08-list-paginated.d.ts +0 -16
- package/dist/examples/08-list-paginated.js +0 -60
- package/dist/examples/08-list-paginated.js.map +0 -1
- package/dist/examples/09-exists.d.ts +0 -13
- package/dist/examples/09-exists.js +0 -32
- package/dist/examples/09-exists.js.map +0 -1
- package/dist/tests/aws-file-manager.test.d.ts +0 -1
- package/dist/tests/aws-file-manager.test.js +0 -359
- package/dist/tests/aws-file-manager.test.js.map +0 -1
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AwsFileManager = void 0;
|
|
4
|
+
exports.fromMulterFile = fromMulterFile;
|
|
5
|
+
exports.fromWebFile = fromWebFile;
|
|
6
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
7
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Adapter helpers — normalise caller-side file representations
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* Adapts a multer file (Express.Multer.File) to FileInput.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // In an Express route with multer:
|
|
17
|
+
* const fileInput = fromMulterFile(req.file);
|
|
18
|
+
*/
|
|
19
|
+
function fromMulterFile(multerFile) {
|
|
20
|
+
return {
|
|
21
|
+
buffer: multerFile.buffer,
|
|
22
|
+
originalName: multerFile.originalname,
|
|
23
|
+
mimeType: multerFile.mimetype,
|
|
24
|
+
size: multerFile.size,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adapts a Web API File (browser / Next.js App Router FormData) to FileInput.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // In a Next.js App Router route handler:
|
|
32
|
+
* const formData = await request.formData();
|
|
33
|
+
* const fileInput = await fromWebFile(formData.get('file') as File);
|
|
34
|
+
*/
|
|
35
|
+
async function fromWebFile(webFile) {
|
|
36
|
+
return {
|
|
37
|
+
buffer: new Uint8Array(await webFile.arrayBuffer()),
|
|
38
|
+
originalName: webFile.name,
|
|
39
|
+
mimeType: webFile.type,
|
|
40
|
+
size: webFile.size,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Main class
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
class AwsFileManager {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
if (!config.region)
|
|
49
|
+
throw new Error("AWS region is required");
|
|
50
|
+
if (!config.bucketName)
|
|
51
|
+
throw new Error("S3 bucket name is required");
|
|
52
|
+
this.bucketName = config.bucketName;
|
|
53
|
+
this.basePath = config.basePath
|
|
54
|
+
? config.basePath.replace(/^\/|\/$/g, "")
|
|
55
|
+
: "";
|
|
56
|
+
this.urlExpirationSeconds =
|
|
57
|
+
config.urlExpirationSeconds ??
|
|
58
|
+
AwsFileManager.DEFAULTS.urlExpirationSeconds;
|
|
59
|
+
this.storageClass =
|
|
60
|
+
config.storageClass ?? AwsFileManager.DEFAULTS.storageClass;
|
|
61
|
+
this.s3 = new client_s3_1.S3Client({
|
|
62
|
+
region: config.region,
|
|
63
|
+
// Disable automatic checksum calculation so presigned PUT URLs don't
|
|
64
|
+
// include x-amz-checksum-crc32 — browsers can't compute or attach that
|
|
65
|
+
// header, which causes CORS preflight failures and checksum mismatches.
|
|
66
|
+
requestChecksumCalculation: "WHEN_REQUIRED",
|
|
67
|
+
...(config.accessKeyId &&
|
|
68
|
+
config.secretAccessKey && {
|
|
69
|
+
credentials: {
|
|
70
|
+
accessKeyId: config.accessKeyId,
|
|
71
|
+
secretAccessKey: config.secretAccessKey,
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// -------------------------------------------------------------------------
|
|
77
|
+
// Upload
|
|
78
|
+
// -------------------------------------------------------------------------
|
|
79
|
+
/**
|
|
80
|
+
* Uploads a file to S3 and returns storage metadata (no URL).
|
|
81
|
+
*
|
|
82
|
+
* The returned `key` is what you persist to your database. Generate signed
|
|
83
|
+
* URLs on demand via `getSignedUrl()` — never store them, as they expire.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // In a pipeline step:
|
|
87
|
+
* const result = await fileManager.upload(ctx.fileInput, { key: ctx.s3Key });
|
|
88
|
+
* ctx.uploadResult = result;
|
|
89
|
+
*/
|
|
90
|
+
async upload(file, options = {}) {
|
|
91
|
+
const { storedName, key } = this.resolveKey(file.originalName, options);
|
|
92
|
+
const command = new client_s3_1.PutObjectCommand({
|
|
93
|
+
Bucket: this.bucketName,
|
|
94
|
+
Key: key,
|
|
95
|
+
Body: file.buffer,
|
|
96
|
+
ContentType: options.contentType ?? file.mimeType,
|
|
97
|
+
Metadata: options.metadata,
|
|
98
|
+
StorageClass: options.storageClass ?? this.storageClass,
|
|
99
|
+
// ACL intentionally omitted — bucket should have BucketOwnerEnforced
|
|
100
|
+
// (AWS default since April 2023). Pass options.acl explicitly only if
|
|
101
|
+
// your bucket was created before that change and requires legacy ACLs.
|
|
102
|
+
});
|
|
103
|
+
const response = await this.s3.send(command);
|
|
104
|
+
return {
|
|
105
|
+
key,
|
|
106
|
+
originalName: file.originalName,
|
|
107
|
+
storedName,
|
|
108
|
+
size: file.size,
|
|
109
|
+
contentType: options.contentType ?? file.mimeType,
|
|
110
|
+
etag: response.ETag?.replace(/"/g, ""),
|
|
111
|
+
storageClass: (options.storageClass ?? this.storageClass),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
// Signed URL — for serving private files to clients
|
|
116
|
+
// -------------------------------------------------------------------------
|
|
117
|
+
/**
|
|
118
|
+
* Generates a short-lived signed URL for a private S3 object.
|
|
119
|
+
*
|
|
120
|
+
* Call this at request time; never store the returned URL. Signed URLs
|
|
121
|
+
* are credentials — treat them accordingly.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* const url = await fileManager.getSignedUrl(file.s3Key, {
|
|
125
|
+
* disposition: 'inline',
|
|
126
|
+
* fileName: file.originalName,
|
|
127
|
+
* });
|
|
128
|
+
*/
|
|
129
|
+
async getSignedUrl(key, options = {}) {
|
|
130
|
+
const disposition = this.buildContentDisposition(options);
|
|
131
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
132
|
+
Bucket: this.bucketName,
|
|
133
|
+
Key: key,
|
|
134
|
+
...(disposition && { ResponseContentDisposition: disposition }),
|
|
135
|
+
});
|
|
136
|
+
return (0, s3_request_presigner_1.getSignedUrl)(this.s3, command, {
|
|
137
|
+
expiresIn: options.expiresIn ?? this.urlExpirationSeconds,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// -------------------------------------------------------------------------
|
|
141
|
+
// Download
|
|
142
|
+
// -------------------------------------------------------------------------
|
|
143
|
+
/**
|
|
144
|
+
* Downloads an S3 object as a Buffer or a Node.js Readable stream.
|
|
145
|
+
*
|
|
146
|
+
* Use `'stream'` (default) when piping to a response or writing to disk.
|
|
147
|
+
* Use `'buffer'` when you need the full bytes in memory (e.g. for processing).
|
|
148
|
+
*
|
|
149
|
+
* Returns `null` when the object does not exist.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const result = await fileManager.download(key, 'buffer');
|
|
153
|
+
* if (result) {
|
|
154
|
+
* const { buffer, metadata } = result;
|
|
155
|
+
* }
|
|
156
|
+
*/
|
|
157
|
+
async download(key, mode) {
|
|
158
|
+
try {
|
|
159
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
160
|
+
Bucket: this.bucketName,
|
|
161
|
+
Key: key,
|
|
162
|
+
});
|
|
163
|
+
const response = await this.s3.send(command);
|
|
164
|
+
if (!response.Body)
|
|
165
|
+
return null;
|
|
166
|
+
const metadata = {
|
|
167
|
+
contentType: response.ContentType,
|
|
168
|
+
contentLength: response.ContentLength,
|
|
169
|
+
lastModified: response.LastModified,
|
|
170
|
+
metadata: response.Metadata,
|
|
171
|
+
storageClass: response.StorageClass,
|
|
172
|
+
};
|
|
173
|
+
if ((mode ?? "stream") === "buffer") {
|
|
174
|
+
const stream = response.Body;
|
|
175
|
+
const chunks = [];
|
|
176
|
+
const buffer = await new Promise((resolve, reject) => {
|
|
177
|
+
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
178
|
+
stream.on("error", reject);
|
|
179
|
+
stream.on("end", () => resolve(Buffer.concat(chunks)));
|
|
180
|
+
});
|
|
181
|
+
return { buffer, metadata };
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
stream: response.Body,
|
|
185
|
+
metadata,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (isNoSuchKeyError(error))
|
|
190
|
+
return null;
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// -------------------------------------------------------------------------
|
|
195
|
+
// Delete
|
|
196
|
+
// -------------------------------------------------------------------------
|
|
197
|
+
/**
|
|
198
|
+
* Permanently deletes an object from S3.
|
|
199
|
+
*
|
|
200
|
+
* Note: this only removes the S3 object. Your database record should be
|
|
201
|
+
* soft-deleted first, and this called as a cleanup step after the DB
|
|
202
|
+
* transaction commits — so a crash mid-way leaves a recoverable orphan
|
|
203
|
+
* rather than a missing file with an intact DB row.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* await fileManager.delete(file.s3Key);
|
|
207
|
+
*/
|
|
208
|
+
async delete(key) {
|
|
209
|
+
const command = new client_s3_1.DeleteObjectCommand({
|
|
210
|
+
Bucket: this.bucketName,
|
|
211
|
+
Key: key,
|
|
212
|
+
});
|
|
213
|
+
await this.s3.send(command);
|
|
214
|
+
// S3 DeleteObject is idempotent — deleting a non-existent key succeeds silently.
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Deletes multiple objects in a single call.
|
|
218
|
+
* Silently skips keys that do not exist.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* await fileManager.deleteMany([original.s3Key, thumbnail.s3Key]);
|
|
222
|
+
*/
|
|
223
|
+
async deleteMany(keys) {
|
|
224
|
+
// S3 batch delete supports up to 1000 keys per request
|
|
225
|
+
const chunks = chunkArray(keys, 1000);
|
|
226
|
+
await Promise.all(chunks.map((chunk) => {
|
|
227
|
+
// Build the delete command inline to avoid importing DeleteObjectsCommand
|
|
228
|
+
// above — keeping the import list tidy and tree-shakeable.
|
|
229
|
+
return Promise.all(chunk.map((key) => this.delete(key)));
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
// -------------------------------------------------------------------------
|
|
233
|
+
// Copy
|
|
234
|
+
// -------------------------------------------------------------------------
|
|
235
|
+
/**
|
|
236
|
+
* Copies an object within the same bucket.
|
|
237
|
+
*
|
|
238
|
+
* Useful when duplicating files across entities (e.g. cloning a note)
|
|
239
|
+
* or reorganising keys without re-uploading bytes.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* await fileManager.copy(sourceFile.s3Key, newKey);
|
|
243
|
+
*/
|
|
244
|
+
async copy(sourceKey, destinationKey, options = {}) {
|
|
245
|
+
const command = new client_s3_1.CopyObjectCommand({
|
|
246
|
+
Bucket: this.bucketName,
|
|
247
|
+
CopySource: `${this.bucketName}/${sourceKey}`,
|
|
248
|
+
Key: destinationKey,
|
|
249
|
+
StorageClass: options.storageClass ?? this.storageClass,
|
|
250
|
+
...(options.metadata && {
|
|
251
|
+
Metadata: options.metadata,
|
|
252
|
+
MetadataDirective: "REPLACE",
|
|
253
|
+
}),
|
|
254
|
+
});
|
|
255
|
+
await this.s3.send(command);
|
|
256
|
+
}
|
|
257
|
+
// -------------------------------------------------------------------------
|
|
258
|
+
// List
|
|
259
|
+
// -------------------------------------------------------------------------
|
|
260
|
+
/**
|
|
261
|
+
* Lists objects under a folder prefix.
|
|
262
|
+
*
|
|
263
|
+
* Results are paginated. Pass the returned `continuationToken` back
|
|
264
|
+
* into subsequent calls to walk through large result sets.
|
|
265
|
+
*
|
|
266
|
+
* Primarily intended for the server-side storage reconciliation job
|
|
267
|
+
* (nightly scan to reconcile DB byte counts against S3 actuals).
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* let token: string | undefined;
|
|
271
|
+
* do {
|
|
272
|
+
* const result = await fileManager.list({ folder: 'acme-corp', continuationToken: token });
|
|
273
|
+
* processBatch(result.entries);
|
|
274
|
+
* token = result.continuationToken;
|
|
275
|
+
* } while (result.hasMore);
|
|
276
|
+
*/
|
|
277
|
+
async list(options = {}) {
|
|
278
|
+
const prefix = this.buildPrefix(options.folder, options.prefix);
|
|
279
|
+
const command = new client_s3_1.ListObjectsV2Command({
|
|
280
|
+
Bucket: this.bucketName,
|
|
281
|
+
Prefix: prefix || undefined,
|
|
282
|
+
MaxKeys: options.maxResults ?? 1000,
|
|
283
|
+
ContinuationToken: options.continuationToken,
|
|
284
|
+
});
|
|
285
|
+
const response = await this.s3.send(command);
|
|
286
|
+
const entries = (response.Contents ?? []).map((obj) => ({
|
|
287
|
+
key: obj.Key ?? "",
|
|
288
|
+
fileName: (obj.Key ?? "").split("/").pop() ?? "",
|
|
289
|
+
size: obj.Size ?? 0,
|
|
290
|
+
lastModified: obj.LastModified ?? new Date(),
|
|
291
|
+
storageClass: obj.StorageClass,
|
|
292
|
+
etag: obj.ETag?.replace(/"/g, ""),
|
|
293
|
+
}));
|
|
294
|
+
return {
|
|
295
|
+
entries,
|
|
296
|
+
continuationToken: response.NextContinuationToken,
|
|
297
|
+
hasMore: response.IsTruncated ?? false,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
// -------------------------------------------------------------------------
|
|
301
|
+
// Key existence check
|
|
302
|
+
// -------------------------------------------------------------------------
|
|
303
|
+
/**
|
|
304
|
+
* Returns true if an object exists at the given key.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* if (!(await fileManager.exists(key))) {
|
|
308
|
+
* throw new Error('Referenced file is missing from storage');
|
|
309
|
+
* }
|
|
310
|
+
*/
|
|
311
|
+
async exists(key) {
|
|
312
|
+
try {
|
|
313
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
314
|
+
Bucket: this.bucketName,
|
|
315
|
+
Key: key,
|
|
316
|
+
});
|
|
317
|
+
await this.s3.send(command);
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
if (isNoSuchKeyError(error))
|
|
322
|
+
return false;
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// -------------------------------------------------------------------------
|
|
327
|
+
// Expose underlying client for advanced use cases
|
|
328
|
+
// -------------------------------------------------------------------------
|
|
329
|
+
/**
|
|
330
|
+
* Returns the underlying S3Client for operations not covered by this class.
|
|
331
|
+
* Use sparingly — prefer adding methods here so the abstraction stays coherent.
|
|
332
|
+
*/
|
|
333
|
+
getS3Client() {
|
|
334
|
+
return this.s3;
|
|
335
|
+
}
|
|
336
|
+
// -------------------------------------------------------------------------
|
|
337
|
+
// Private helpers
|
|
338
|
+
// -------------------------------------------------------------------------
|
|
339
|
+
/**
|
|
340
|
+
* Resolves the final S3 key and stored filename from upload options.
|
|
341
|
+
*
|
|
342
|
+
* Priority order for the key:
|
|
343
|
+
* 1. options.key (explicit full key — pipeline usage)
|
|
344
|
+
* 2. basePath + folder + fileName (if provided)
|
|
345
|
+
* 3. basePath + folder + UUID-based name (if generateUniqueFileName)
|
|
346
|
+
* 4. basePath + folder + originalName (fallback)
|
|
347
|
+
*/
|
|
348
|
+
resolveKey(originalName, options) {
|
|
349
|
+
if (options.key) {
|
|
350
|
+
const storedName = options.key.split("/").pop() ?? originalName;
|
|
351
|
+
return { key: options.key, storedName };
|
|
352
|
+
}
|
|
353
|
+
const storedName = options.generateUniqueFileName
|
|
354
|
+
? this.makeUniqueFileName(originalName)
|
|
355
|
+
: (options.fileName ?? originalName);
|
|
356
|
+
const key = this.buildFullKey(storedName, options.folder);
|
|
357
|
+
return { key, storedName };
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Builds a full S3 key from basePath, optional folder, and filename.
|
|
361
|
+
*/
|
|
362
|
+
buildFullKey(fileName, folder) {
|
|
363
|
+
const folderPart = folder ? folder.replace(/^\/|\/$/g, "") : "";
|
|
364
|
+
return [this.basePath, folderPart, fileName]
|
|
365
|
+
.filter((part) => part.length > 0)
|
|
366
|
+
.join("/");
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Builds a prefix string for list operations.
|
|
370
|
+
*/
|
|
371
|
+
buildPrefix(folder, prefix) {
|
|
372
|
+
return [
|
|
373
|
+
this.basePath,
|
|
374
|
+
folder ? folder.replace(/^\/|\/$/g, "") : "",
|
|
375
|
+
prefix ?? "",
|
|
376
|
+
]
|
|
377
|
+
.filter((part) => part.length > 0)
|
|
378
|
+
.join("/");
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Generates a UUID-based filename, preserving the original extension.
|
|
382
|
+
* UUIDs are collision-proof under any upload concurrency.
|
|
383
|
+
*/
|
|
384
|
+
makeUniqueFileName(originalName) {
|
|
385
|
+
const ext = originalName.includes(".")
|
|
386
|
+
? originalName.substring(originalName.lastIndexOf("."))
|
|
387
|
+
: "";
|
|
388
|
+
return `${(0, crypto_1.randomUUID)()}${ext}`;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Builds a Content-Disposition header value from SignedUrlOptions.
|
|
392
|
+
*/
|
|
393
|
+
buildContentDisposition(options) {
|
|
394
|
+
if (!options.disposition)
|
|
395
|
+
return undefined;
|
|
396
|
+
if (options.disposition === "attachment" && options.fileName) {
|
|
397
|
+
const safe = encodeURIComponent(options.fileName);
|
|
398
|
+
return `attachment; filename="${safe}"; filename*=UTF-8''${safe}`;
|
|
399
|
+
}
|
|
400
|
+
return options.disposition; // 'inline' or bare 'attachment'
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
exports.AwsFileManager = AwsFileManager;
|
|
404
|
+
AwsFileManager.DEFAULTS = {
|
|
405
|
+
storageClass: client_s3_1.StorageClass.INTELLIGENT_TIERING,
|
|
406
|
+
urlExpirationSeconds: 3600,
|
|
407
|
+
};
|
|
408
|
+
// ---------------------------------------------------------------------------
|
|
409
|
+
// Module-level utilities
|
|
410
|
+
// ---------------------------------------------------------------------------
|
|
411
|
+
/** Type guard for S3 NoSuchKey errors */
|
|
412
|
+
function isNoSuchKeyError(error) {
|
|
413
|
+
return (typeof error === "object" &&
|
|
414
|
+
error !== null &&
|
|
415
|
+
"name" in error &&
|
|
416
|
+
error.name === "NoSuchKey");
|
|
417
|
+
}
|
|
418
|
+
/** Splits an array into chunks of at most `size` elements */
|
|
419
|
+
function chunkArray(arr, size) {
|
|
420
|
+
const chunks = [];
|
|
421
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
422
|
+
chunks.push(arr.slice(i, i + size));
|
|
423
|
+
}
|
|
424
|
+
return chunks;
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=aws-file-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-file-manager.js","sourceRoot":"","sources":["../../lib/aws-file-manager.ts"],"names":[],"mappings":";;;AA6LA,wCAYC;AAUD,kCAOC;AA1ND,kDAQ4B;AAC5B,wEAA6D;AAC7D,mCAAoC;AAwKpC,8EAA8E;AAC9E,+DAA+D;AAC/D,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,UAK9B;IACC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAAC,OAAa;IAC7C,OAAO;QACL,MAAM,EAAE,IAAI,UAAU,CAAC,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;QACnD,YAAY,EAAE,OAAO,CAAC,IAAI;QAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAa,cAAc;IAYzB,YAAY,MAA4B;QACtC,IAA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AC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -32,7 +32,7 @@ export interface AwsFileManagerConfig {
|
|
|
32
32
|
*/
|
|
33
33
|
export interface FileInput {
|
|
34
34
|
/** Raw file bytes */
|
|
35
|
-
buffer:
|
|
35
|
+
buffer: Uint8Array;
|
|
36
36
|
/** Original filename as provided by the uploader */
|
|
37
37
|
originalName: string;
|
|
38
38
|
/** MIME type, e.g. 'image/jpeg' */
|
|
@@ -29,7 +29,7 @@ export function fromMulterFile(multerFile) {
|
|
|
29
29
|
*/
|
|
30
30
|
export async function fromWebFile(webFile) {
|
|
31
31
|
return {
|
|
32
|
-
buffer:
|
|
32
|
+
buffer: new Uint8Array(await webFile.arrayBuffer()),
|
|
33
33
|
originalName: webFile.name,
|
|
34
34
|
mimeType: webFile.type,
|
|
35
35
|
size: webFile.size,
|
|
@@ -55,6 +55,10 @@ export class AwsFileManager {
|
|
|
55
55
|
config.storageClass ?? AwsFileManager.DEFAULTS.storageClass;
|
|
56
56
|
this.s3 = new S3Client({
|
|
57
57
|
region: config.region,
|
|
58
|
+
// Disable automatic checksum calculation so presigned PUT URLs don't
|
|
59
|
+
// include x-amz-checksum-crc32 — browsers can't compute or attach that
|
|
60
|
+
// header, which causes CORS preflight failures and checksum mismatches.
|
|
61
|
+
requestChecksumCalculation: "WHEN_REQUIRED",
|
|
58
62
|
...(config.accessKeyId &&
|
|
59
63
|
config.secretAccessKey && {
|
|
60
64
|
credentials: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-file-manager.js","sourceRoot":"","sources":["../../lib/aws-file-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM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AAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allegria/aws-file-manager",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "TypeScript library for managing files in AWS S3",
|
|
5
|
-
"main": "dist/
|
|
5
|
+
"main": "dist/cjs/aws-file-manager.js",
|
|
6
|
+
"module": "dist/lib/aws-file-manager.js",
|
|
6
7
|
"types": "dist/lib/aws-file-manager.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/lib/aws-file-manager.d.ts",
|
|
12
|
+
"default": "./dist/lib/aws-file-manager.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/cjs/aws-file-manager.d.ts",
|
|
16
|
+
"default": "./dist/cjs/aws-file-manager.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"files": [
|
|
8
21
|
"dist",
|
|
9
22
|
"examples"
|
|
10
23
|
],
|
|
11
24
|
"type": "module",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}, null, 2))\"",
|
|
27
|
+
"start": "pnpm run build",
|
|
28
|
+
"prepare": "pnpm run build",
|
|
29
|
+
"prepublishOnly": "pnpm run build",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest"
|
|
32
|
+
},
|
|
12
33
|
"keywords": [
|
|
13
34
|
"aws",
|
|
14
35
|
"s3",
|
|
@@ -40,11 +61,8 @@
|
|
|
40
61
|
"typescript": "^5.2.2",
|
|
41
62
|
"vitest": "^4.0.18"
|
|
42
63
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"start": "pnpm run build",
|
|
47
|
-
"test": "vitest run",
|
|
48
|
-
"test:watch": "vitest"
|
|
64
|
+
"volta": {
|
|
65
|
+
"node": "20.20.0",
|
|
66
|
+
"pnpm": "9.1.0"
|
|
49
67
|
}
|
|
50
|
-
}
|
|
68
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 01-setup.ts
|
|
3
|
-
*
|
|
4
|
-
* Instantiation patterns for AwsFileManager.
|
|
5
|
-
*
|
|
6
|
-
* Three approaches:
|
|
7
|
-
* A) Explicit credentials — for local dev / environments without IAM
|
|
8
|
-
* B) Environment variables — SDK picks up AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY automatically
|
|
9
|
-
* C) IAM role — recommended for production (EC2, ECS, Lambda)
|
|
10
|
-
*/
|
|
11
|
-
declare const fileManagerExplicit: any;
|
|
12
|
-
declare const fileManagerEnv: any;
|
|
13
|
-
declare const fileManager: any;
|
|
14
|
-
export { fileManager, fileManagerEnv, fileManagerExplicit };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 01-setup.ts
|
|
3
|
-
*
|
|
4
|
-
* Instantiation patterns for AwsFileManager.
|
|
5
|
-
*
|
|
6
|
-
* Three approaches:
|
|
7
|
-
* A) Explicit credentials — for local dev / environments without IAM
|
|
8
|
-
* B) Environment variables — SDK picks up AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY automatically
|
|
9
|
-
* C) IAM role — recommended for production (EC2, ECS, Lambda)
|
|
10
|
-
*/
|
|
11
|
-
import { AwsFileManager } from "@lib/aws-file-manager";
|
|
12
|
-
// ─── A) Explicit credentials ──────────────────────────────────────────────────
|
|
13
|
-
// Pass credentials directly. Useful during local development when you have a
|
|
14
|
-
// dedicated IAM user with limited S3 permissions.
|
|
15
|
-
const fileManagerExplicit = new AwsFileManager({
|
|
16
|
-
region: "us-east-1",
|
|
17
|
-
bucketName: "my-app-uploads",
|
|
18
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
19
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
20
|
-
});
|
|
21
|
-
// ─── B) Environment variable resolution ───────────────────────────────────────
|
|
22
|
-
// Omit credentials — the AWS SDK resolves them from:
|
|
23
|
-
// AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY environment variables, or
|
|
24
|
-
// ~/.aws/credentials file (local dev with aws-cli configured)
|
|
25
|
-
const fileManagerEnv = new AwsFileManager({
|
|
26
|
-
region: "us-east-1",
|
|
27
|
-
bucketName: "my-app-uploads",
|
|
28
|
-
});
|
|
29
|
-
// ─── C) IAM role (production recommended) ─────────────────────────────────────
|
|
30
|
-
// When running on EC2 / ECS / Lambda with an attached IAM role, omit all
|
|
31
|
-
// credentials. The SDK automatically uses the instance metadata service.
|
|
32
|
-
// No secrets in code or environment variables — the most secure option.
|
|
33
|
-
const fileManager = new AwsFileManager({
|
|
34
|
-
region: process.env.AWS_REGION ?? "us-east-1",
|
|
35
|
-
bucketName: process.env.S3_BUCKET_NAME,
|
|
36
|
-
// Optional: namespace all writes under a sub-folder
|
|
37
|
-
basePath: "uploads",
|
|
38
|
-
// Optional: default signed URL TTL (default: 3600 seconds)
|
|
39
|
-
urlExpirationSeconds: 7200,
|
|
40
|
-
});
|
|
41
|
-
export { fileManager, fileManagerEnv, fileManagerExplicit };
|
|
42
|
-
//# sourceMappingURL=01-setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"01-setup.js","sourceRoot":"","sources":["../../examples/01-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,iFAAiF;AACjF,6EAA6E;AAC7E,kDAAkD;AAElD,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAC;IAC7C,MAAM,EAAE,WAAW;IACnB,UAAU,EAAE,gBAAgB;IAC5B,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAkB;IAC3C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAsB;CACpD,CAAC,CAAC;AAEH,iFAAiF;AACjF,qDAAqD;AACrD,wEAAwE;AACxE,gEAAgE;AAEhE,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC;IACxC,MAAM,EAAE,WAAW;IACnB,UAAU,EAAE,gBAAgB;CAC7B,CAAC,CAAC;AAEH,iFAAiF;AACjF,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AAExE,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;IAC7C,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,cAAe;IACvC,oDAAoD;IACpD,QAAQ,EAAE,SAAS;IACnB,2DAA2D;IAC3D,oBAAoB,EAAE,IAAI;CAC3B,CAAC,CAAC;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 02-upload-multer.ts
|
|
3
|
-
*
|
|
4
|
-
* Uploading files from an Express route that uses multer for multipart parsing.
|
|
5
|
-
*
|
|
6
|
-
* Key points:
|
|
7
|
-
* - Use `fromMulterFile()` to normalise multer's file shape into FileInput.
|
|
8
|
-
* - `upload()` returns an UploadResult with the S3 key — persist this key
|
|
9
|
-
* to your database, NOT a signed URL (URLs expire).
|
|
10
|
-
* - Generate a signed URL on demand at request time via `getSignedUrl()`.
|
|
11
|
-
*/
|
|
12
|
-
declare const app: import("express-serve-static-core").Express;
|
|
13
|
-
export { app };
|