@fluxmedia/s3 0.1.0-alpha.0 → 0.1.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/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # @fluxmedia/s3
2
2
 
3
- AWS S3 provider for FluxMedia.
3
+ AWS S3 provider for FluxMedia - simple, reliable file storage with the AWS ecosystem.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pnpm add @fluxmedia/core @fluxmedia/s3 @aws-sdk/client-s3
8
+ pnpm add @fluxmedia/core @fluxmedia/s3 @aws-sdk/client-s3 @aws-sdk/lib-storage
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Quick Start
12
12
 
13
13
  ```typescript
14
14
  import { MediaUploader } from '@fluxmedia/core';
@@ -18,59 +18,126 @@ const uploader = new MediaUploader(
18
18
  new S3Provider({
19
19
  region: 'us-east-1',
20
20
  bucket: 'my-bucket',
21
- accessKeyId: 'your-access-key',
22
- secretAccessKey: 'your-secret-key'
23
- }),
21
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
22
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
23
+ })
24
24
  );
25
25
 
26
+ // Upload a file
26
27
  const result = await uploader.upload(file, {
27
28
  folder: 'uploads',
28
29
  filename: 'my-file.jpg'
29
30
  });
30
31
 
31
32
  console.log(result.url);
33
+ // https://my-bucket.s3.us-east-1.amazonaws.com/uploads/my-file.jpg
32
34
  ```
33
35
 
34
36
  ## Features
35
37
 
36
- S3 is a storage-only provider:
37
-
38
- - File upload/download
39
- - Multipart upload for large files
40
- - Signed upload URLs
41
- - No image transformations (use CloudFront + Lambda@Edge)
42
- - No video processing
38
+ - **Automatic multipart uploads** for files >5MB
39
+ - **Progress tracking** for individual and batch uploads
40
+ - **Batch operations** with concurrency control
41
+ - **S3-compatible** - works with MinIO, DigitalOcean Spaces, etc.
43
42
 
44
43
  ## Configuration
45
44
 
46
45
  ```typescript
47
46
  interface S3Config {
48
- region: string; // AWS region
49
- bucket: string; // S3 bucket name
50
- accessKeyId: string; // AWS Access Key
51
- secretAccessKey: string; // AWS Secret Key
52
- endpoint?: string; // Custom endpoint (for S3-compatible)
53
- forcePathStyle?: boolean; // Force path style URLs
47
+ region: string; // AWS region (e.g., 'us-east-1')
48
+ bucket: string; // S3 bucket name
49
+ accessKeyId: string; // AWS Access Key
50
+ secretAccessKey: string; // AWS Secret Key
51
+ endpoint?: string; // Custom endpoint for S3-compatible services
52
+ forcePathStyle?: boolean; // Use path-style URLs
54
53
  }
55
54
  ```
56
55
 
56
+ ## Upload with Progress
57
+
58
+ ```typescript
59
+ const result = await uploader.upload(file, {
60
+ folder: 'uploads',
61
+ onProgress: (percent) => {
62
+ console.log(`Upload progress: ${percent}%`);
63
+ }
64
+ });
65
+ ```
66
+
67
+ ## Batch Uploads
68
+
69
+ Upload multiple files with concurrency control:
70
+
71
+ ```typescript
72
+ const results = await uploader.uploadMultiple(files, {
73
+ folder: 'batch-uploads',
74
+ concurrency: 5,
75
+ onBatchProgress: (completed, total) => {
76
+ console.log(`Uploaded ${completed}/${total} files`);
77
+ }
78
+ });
79
+ ```
80
+
81
+ ## Delete Files
82
+
83
+ ```typescript
84
+ // Delete single file
85
+ await uploader.delete(result.id);
86
+
87
+ // Delete multiple files
88
+ await uploader.deleteMultiple(['file1', 'file2', 'file3']);
89
+ ```
90
+
91
+ ## Native SDK Access
92
+
93
+ Access the underlying AWS S3 client for advanced operations:
94
+
95
+ ```typescript
96
+ const s3Client = uploader.provider.native;
97
+
98
+ // Use native AWS SDK methods
99
+ const { ListBucketsCommand } = await import('@aws-sdk/client-s3');
100
+ const buckets = await s3Client.send(new ListBucketsCommand({}));
101
+ ```
102
+
57
103
  ## S3-Compatible Services
58
104
 
59
- Works with S3-compatible services like MinIO, DigitalOcean Spaces:
105
+ Works with DigitalOcean Spaces, MinIO, and other S3-compatible services:
60
106
 
61
107
  ```typescript
108
+ // DigitalOcean Spaces
62
109
  const uploader = new MediaUploader(
63
110
  new S3Provider({
64
111
  region: 'nyc3',
65
112
  bucket: 'my-space',
66
113
  accessKeyId: 'your-key',
67
114
  secretAccessKey: 'your-secret',
68
- endpoint: 'https://nyc3.digitaloceanspaces.com',
69
- forcePathStyle: false
115
+ endpoint: 'https://nyc3.digitaloceanspaces.com'
116
+ })
117
+ );
118
+
119
+ // MinIO (self-hosted)
120
+ const uploader = new MediaUploader(
121
+ new S3Provider({
122
+ region: 'us-east-1',
123
+ bucket: 'my-bucket',
124
+ accessKeyId: 'minio-key',
125
+ secretAccessKey: 'minio-secret',
126
+ endpoint: 'http://localhost:9000',
127
+ forcePathStyle: true
70
128
  })
71
129
  );
72
130
  ```
73
131
 
132
+ ## Environment Variables
133
+
134
+ ```bash
135
+ AWS_ACCESS_KEY_ID=your-access-key
136
+ AWS_SECRET_ACCESS_KEY=your-secret-key
137
+ AWS_REGION=us-east-1
138
+ S3_BUCKET=my-bucket
139
+ ```
140
+
74
141
  ## License
75
142
 
76
143
  MIT