@allegria/aws-file-manager 0.0.1

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 ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017 Ryan Sukale <ryansukale@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # AWS File Manager
2
+
3
+ A TypeScript library for managing files in AWS S3.
4
+
5
+ ## Features
6
+
7
+ - Upload and download files from S3
8
+ - Fully typed with TypeScript
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @allegria/aws-file-manager
14
+ ```
15
+
16
+ ## Examples
17
+
18
+ #### Basic usage
19
+
20
+ ```js
21
+ const fileManager = new AwsFileManager({
22
+ region: AWS_REGION,
23
+ bucketName: AWS_BUCKET_NAME,
24
+ accessKeyId: AWS_ACCESS_KEY,
25
+ secretAccessKey: AWS_SECRET_ACCESS_KEY,
26
+ });
27
+
28
+ // To upload
29
+ const uploadResult = await fileManager.upload('my-photo.jpg');
30
+
31
+ // To download
32
+ const downloadResult = await fileManager.download('my-photo.jpg', 'buffer');
33
+ ```
@@ -0,0 +1,158 @@
1
+ import { S3Client, StorageClass } from "@aws-sdk/client-s3";
2
+ import type { Readable } from "stream";
3
+ /**
4
+ * Configuration options for the AWS File Manager
5
+ */
6
+ export interface AwsFileManagerConfig {
7
+ /** AWS region */
8
+ region: string;
9
+ /** S3 bucket name */
10
+ bucketName: string;
11
+ /** AWS access key ID (optional if using environment variables) */
12
+ accessKeyId?: string;
13
+ /** AWS secret access key (optional if using environment variables) */
14
+ secretAccessKey?: string;
15
+ /** Default S3 ACL ('private', 'public-read', etc.) (default: 'private') */
16
+ acl?: string;
17
+ /** Base folder path in the bucket (default: '') */
18
+ basePath?: string;
19
+ /** URL expiration time in seconds for signed URLs (default: 3600) */
20
+ urlExpirationSeconds?: number;
21
+ /** Default storage class for uploaded files (default: 'STANDARD') */
22
+ storageClass?: StorageClass;
23
+ }
24
+ /**
25
+ * Options for uploading a file to S3
26
+ */
27
+ export interface UploadOptions {
28
+ /** Folder path in the bucket (appended to basePath) */
29
+ folder?: string;
30
+ /** Override the file's content type */
31
+ contentType?: string;
32
+ /** Override the default ACL */
33
+ acl?: string;
34
+ /** Custom file name */
35
+ fileName?: string;
36
+ generateFileName?: boolean;
37
+ /** Additional metadata for the file */
38
+ metadata?: Record<string, string>;
39
+ /** S3 storage class for the file */
40
+ storageClass?: StorageClass;
41
+ }
42
+ /**
43
+ * Options for finding files in S3
44
+ */
45
+ export interface FindOptions {
46
+ /** Folder path to search in (appended to basePath) */
47
+ folder?: string;
48
+ /** Maximum number of results to return */
49
+ maxResults?: number;
50
+ /** Continuation token for pagination */
51
+ continuationToken?: string;
52
+ /** Filter by file prefix */
53
+ prefix?: string;
54
+ /** Generate signed URLs for the files */
55
+ generateUrls?: boolean;
56
+ }
57
+ /**
58
+ * Result of a successful S3 upload
59
+ */
60
+ export interface FileResult {
61
+ /** The S3 object key */
62
+ key: string;
63
+ /** The URL of the file (signed or public depending on ACL) */
64
+ url: string;
65
+ /** The file name */
66
+ fileName: string;
67
+ /** The original file name (for uploads) */
68
+ originalName?: string;
69
+ /** The file size in bytes */
70
+ size?: number;
71
+ /** The file's MIME type */
72
+ contentType?: string;
73
+ /** The ETag from S3 */
74
+ etag?: string;
75
+ /** Last modified date */
76
+ lastModified?: Date;
77
+ /** Additional metadata */
78
+ metadata?: Record<string, string>;
79
+ /** Storage class of the file */
80
+ storageClass?: string;
81
+ }
82
+ /**
83
+ * Result of a find operation
84
+ */
85
+ export interface FindResult {
86
+ /** List of files found */
87
+ files: FileResult[];
88
+ /** Continuation token for pagination */
89
+ continuationToken?: string;
90
+ /** Whether there are more results */
91
+ hasMore: boolean;
92
+ }
93
+ export type DownloadMode = "buffer" | "stream";
94
+ export type DownloadResult<T extends DownloadMode> = T extends "buffer" ? {
95
+ buffer: Buffer;
96
+ metadata: Record<string, any>;
97
+ } : {
98
+ stream: Readable;
99
+ metadata: Record<string, any>;
100
+ };
101
+ /**
102
+ * AWS File Manager class for handling S3 file operations
103
+ */
104
+ export default class AwsFileManager {
105
+ private s3Client;
106
+ private bucketName;
107
+ private acl;
108
+ private basePath;
109
+ private urlExpirationSeconds;
110
+ private storageClass;
111
+ static DEFAULTS: {
112
+ storageClass: "INTELLIGENT_TIERING";
113
+ urlExpirationSeconds: number;
114
+ };
115
+ /**
116
+ * Creates a new AWS File Manager instance
117
+ * @param config - Configuration options
118
+ */
119
+ constructor(config: AwsFileManagerConfig);
120
+ /**
121
+ * Generates a full S3 key including the base path and folder
122
+ * @param fileName - The file name
123
+ * @param folder - Optional folder path
124
+ * @returns Full S3 key
125
+ */
126
+ private getFullKey;
127
+ /**
128
+ * Generates a file name for S3
129
+ * @param originalName - The original file name
130
+ * @param customName - Optional custom file name
131
+ * @returns Generated file name
132
+ */
133
+ private generateFileName;
134
+ /**
135
+ * Uploads a single file to S3
136
+ * @param file - The file to upload (Buffer or Multer file)
137
+ * @param options - Upload options
138
+ * @returns Upload result
139
+ */
140
+ upload(file: File, options?: UploadOptions): Promise<FileResult>;
141
+ /**
142
+ * Downloads a file from S3
143
+ * @param key - The S3 object key
144
+ * @returns File buffer and metadata or null if not found
145
+ */
146
+ download<T extends DownloadMode = "stream">(key: string, mode?: T): Promise<{
147
+ buffer: Buffer;
148
+ metadata: Record<string, any>;
149
+ } | {
150
+ stream: Readable;
151
+ metadata: Record<string, any>;
152
+ } | null>;
153
+ /**
154
+ * Gets the S3 client instance
155
+ * @returns S3 client
156
+ */
157
+ getS3Client(): S3Client;
158
+ }
@@ -0,0 +1,181 @@
1
+ import { S3Client, PutObjectCommand, GetObjectCommand, StorageClass, } from "@aws-sdk/client-s3";
2
+ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
3
+ /**
4
+ * AWS File Manager class for handling S3 file operations
5
+ */
6
+ class AwsFileManager {
7
+ /**
8
+ * Creates a new AWS File Manager instance
9
+ * @param config - Configuration options
10
+ */
11
+ constructor(config) {
12
+ // Validate required config
13
+ if (!config.region)
14
+ throw new Error("AWS region is required");
15
+ if (!config.bucketName)
16
+ throw new Error("S3 bucket name is required");
17
+ // Set defaults
18
+ this.acl = config.acl || "private";
19
+ this.basePath = config.basePath
20
+ ? config.basePath.replace(/^\/|\/$/g, "")
21
+ : "";
22
+ this.bucketName = config.bucketName;
23
+ this.urlExpirationSeconds =
24
+ config.urlExpirationSeconds ||
25
+ AwsFileManager.DEFAULTS.urlExpirationSeconds;
26
+ this.storageClass =
27
+ config.storageClass || AwsFileManager.DEFAULTS.storageClass;
28
+ // Create S3 client with provided credentials or from environment variables
29
+ const s3ClientOptions = {
30
+ region: config.region,
31
+ };
32
+ // Add credentials if provided
33
+ if (config.accessKeyId && config.secretAccessKey) {
34
+ s3ClientOptions.credentials = {
35
+ accessKeyId: config.accessKeyId,
36
+ secretAccessKey: config.secretAccessKey,
37
+ };
38
+ }
39
+ this.s3Client = new S3Client(s3ClientOptions);
40
+ }
41
+ /**
42
+ * Generates a full S3 key including the base path and folder
43
+ * @param fileName - The file name
44
+ * @param folder - Optional folder path
45
+ * @returns Full S3 key
46
+ */
47
+ getFullKey(fileName, folder) {
48
+ const folderPath = folder ? folder.replace(/^\/|\/$/g, "") : "";
49
+ const parts = [this.basePath, folderPath, fileName].filter((part) => part.length > 0);
50
+ return parts.join("/");
51
+ }
52
+ /**
53
+ * Generates a file name for S3
54
+ * @param originalName - The original file name
55
+ * @param customName - Optional custom file name
56
+ * @returns Generated file name
57
+ */
58
+ generateFileName(originalName) {
59
+ const timestamp = Date.now();
60
+ const extension = originalName.includes(".")
61
+ ? originalName.substring(originalName.lastIndexOf("."))
62
+ : "";
63
+ const baseName = originalName.includes(".")
64
+ ? originalName.substring(0, originalName.lastIndexOf("."))
65
+ : originalName;
66
+ return `${baseName}-${timestamp}${extension}`;
67
+ }
68
+ /**
69
+ * Uploads a single file to S3
70
+ * @param file - The file to upload (Buffer or Multer file)
71
+ * @param options - Upload options
72
+ * @returns Upload result
73
+ */
74
+ async upload(file, options = {}) {
75
+ if (!file) {
76
+ throw new Error("Invalid file object");
77
+ }
78
+ const buffer = Buffer.from(await file.arrayBuffer());
79
+ if (!buffer) {
80
+ throw new Error("Invalid file object");
81
+ }
82
+ const fileName = options.generateFileName
83
+ ? this.generateFileName(file.name)
84
+ : options.fileName || file.name;
85
+ const key = this.getFullKey(fileName, options.folder);
86
+ const uploadParams = {
87
+ Bucket: this.bucketName,
88
+ Key: key,
89
+ Body: buffer,
90
+ ContentType: options.contentType || file.type,
91
+ ACL: options.acl || this.acl,
92
+ Metadata: options.metadata,
93
+ StorageClass: options.storageClass || this.storageClass,
94
+ };
95
+ const command = new PutObjectCommand(uploadParams);
96
+ const result = await this.s3Client.send(command);
97
+ // Generate the URL for the uploaded file
98
+ let url;
99
+ if (uploadParams.ACL === "public-read") {
100
+ // Public URL
101
+ url = `https://${this.bucketName}.s3.amazonaws.com/${key}`;
102
+ }
103
+ else {
104
+ // Signed URL
105
+ const getCommand = new GetObjectCommand({
106
+ Bucket: this.bucketName,
107
+ Key: key,
108
+ });
109
+ url = await getSignedUrl(this.s3Client, getCommand, {
110
+ expiresIn: this.urlExpirationSeconds,
111
+ });
112
+ }
113
+ return {
114
+ key,
115
+ url,
116
+ fileName,
117
+ originalName: file.name,
118
+ size: file.size,
119
+ contentType: file.type,
120
+ etag: result.ETag?.replace(/"/g, ""), // Remove quotes from ETag
121
+ storageClass: uploadParams.StorageClass,
122
+ };
123
+ }
124
+ /**
125
+ * Downloads a file from S3
126
+ * @param key - The S3 object key
127
+ * @returns File buffer and metadata or null if not found
128
+ */
129
+ async download(key, mode) {
130
+ try {
131
+ const command = new GetObjectCommand({
132
+ Bucket: this.bucketName,
133
+ Key: key,
134
+ });
135
+ const result = await this.s3Client.send(command);
136
+ if (!result.Body)
137
+ return null;
138
+ const metadata = {
139
+ contentType: result.ContentType,
140
+ contentLength: result.ContentLength,
141
+ lastModified: result.LastModified,
142
+ metadata: result.Metadata,
143
+ storageClass: result.StorageClass,
144
+ };
145
+ const effectiveMode = mode ?? "stream";
146
+ if (effectiveMode === "buffer") {
147
+ const stream = result.Body;
148
+ const chunks = [];
149
+ const buffer = await new Promise((resolve, reject) => {
150
+ stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
151
+ stream.on("error", reject);
152
+ stream.on("end", () => resolve(Buffer.concat(chunks)));
153
+ });
154
+ return { buffer, metadata };
155
+ }
156
+ return {
157
+ stream: result.Body,
158
+ metadata,
159
+ };
160
+ }
161
+ catch (error) {
162
+ console.error("Error downloading file:", error);
163
+ return null;
164
+ }
165
+ }
166
+ /**
167
+ * Gets the S3 client instance
168
+ * @returns S3 client
169
+ */
170
+ getS3Client() {
171
+ return this.s3Client;
172
+ }
173
+ }
174
+ AwsFileManager.DEFAULTS = {
175
+ // Default storage class for all AwsFileManager instances
176
+ storageClass: StorageClass.INTELLIGENT_TIERING,
177
+ // 1 hour
178
+ urlExpirationSeconds: 3600,
179
+ };
180
+ export default AwsFileManager;
181
+ //# 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":"AAAA,OAAO,EAEL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAyG7D;;GAEG;AACH,MAAqB,cAAc;IAejC;;;OAGG;IACH,YAAY,MAA4B;QACtC,2BAA2B;QAC3B,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEtE,eAAe;QACf,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,SAAS,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;YAC7B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACzC,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,oBAAoB;YACvB,MAAM,CAAC,oBAAoB;gBAC3B,cAAc,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QAC/C,IAAI,CAAC,YAAY;YACf,MAAM,CAAC,YAAY,IAAI,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QAE9D,2EAA2E;QAC3E,MAAM,eAAe,GAGjB;YACF,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;QAEF,8BAA8B;QAC9B,IAAI,MAAM,CAAC,WAAW,IAAI,M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AAI,IAAI,QAAQ,CAAC;YAEvC,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;gBAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAgB,CAAC;gBACvC,MAAM,MAAM,GAAa,EAAE,CAAC;gBAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;oBAC3D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC9D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC3B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACzD,CAAC,CAAC,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkC,CAAC;YAC9D,CAAC;YACD,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,IAAgB;gBAC/B,QAAQ;aACuB,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;;AA7MM,uBAAQ,GAAG;IAChB,yDAAyD;IACzD,YAAY,EAAE,YAAY,CAAC,mBAAmB;IAC9C,SAAS;IACT,oBAAoB,EAAE,IAAI;CAC3B,CAAC;eAbiB,cAAc"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@allegria/aws-file-manager",
3
+ "version": "0.0.1",
4
+ "description": "TypeScript library for managing files in AWS S3",
5
+ "main": "dist/lib/aws-file-manager.js",
6
+ "types": "dist/lib/aws-file-manager.d.ts",
7
+ "files": ["dist"],
8
+ "type": "module",
9
+ "scripts": {
10
+ "preinstall": "npx only-allow pnpm",
11
+ "build": "tsc",
12
+ "start": "pnpm run build",
13
+ "prepare": "pnpm run build",
14
+ "prepublishOnly": "pnpm run build"
15
+ },
16
+ "keywords": ["aws", "s3", "file-upload", "file-manager", "typescript"],
17
+ "author": "",
18
+ "license": "MIT",
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@aws-sdk/client-s3": "^3.445.0",
24
+ "@aws-sdk/s3-request-presigner": "^3.445.0",
25
+ "dotenv": "^16.3.1",
26
+ "express": "^4.18.2",
27
+ "jszip": "^3.10.1",
28
+ "multer": "^1.4.5-lts.1"
29
+ },
30
+ "devDependencies": {
31
+ "@types/express": "^4.17.21",
32
+ "@types/multer": "^1.4.10",
33
+ "@types/node": "^20.9.0",
34
+ "ts-node": "^10.9.1",
35
+ "typescript": "^5.2.2"
36
+ }
37
+ }
38
+