@veap/storage 0.1.5 → 0.1.7
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 +17 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ and extension validation, deduplication hashing, and driver routing.
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
- **Multi-driver architecture**: Pluggable `
|
|
19
|
+
- **Multi-driver architecture**: Pluggable `IStorageProvider` interface
|
|
20
20
|
allowing concurrent drivers (for example, local disk for uploads, S3 for archives).
|
|
21
21
|
- **Default local provider**: Ready-to-use `LocalFileProvider` saving files to
|
|
22
22
|
configurable public or private application directories.
|
|
@@ -85,30 +85,34 @@ export async function uploadAvatar(formData: FormData) {
|
|
|
85
85
|
throw new Error(result.error);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
return { url: result.url,
|
|
88
|
+
return { url: result.url, serviceId: result.serviceId };
|
|
89
89
|
}
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
### Implementing a Custom Storage Driver
|
|
93
93
|
|
|
94
94
|
Create custom cloud storage drivers (for example, AWS S3 or Cloudflare R2) by
|
|
95
|
-
implementing the `
|
|
95
|
+
implementing the `IStorageProvider` interface:
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
|
-
import type {
|
|
98
|
+
import type { IStorageProvider, StorageResult } from "@veap/storage";
|
|
99
99
|
|
|
100
|
-
export class S3StorageProvider implements
|
|
100
|
+
export class S3StorageProvider implements IStorageProvider {
|
|
101
101
|
public id = "s3";
|
|
102
102
|
|
|
103
|
-
async upload(file:
|
|
103
|
+
async upload(file: File): Promise<StorageResult> {
|
|
104
104
|
// Perform upload to S3 bucket
|
|
105
105
|
return {
|
|
106
|
+
name: file.name,
|
|
106
107
|
url: `https://my-bucket.s3.amazonaws.com/${file.name}`,
|
|
107
|
-
|
|
108
|
+
type: file.type,
|
|
109
|
+
size: file.size,
|
|
110
|
+
service: "s3",
|
|
111
|
+
serviceId: `uploads/${file.name}`,
|
|
108
112
|
};
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
async delete(
|
|
115
|
+
async delete(serviceId: string): Promise<boolean> {
|
|
112
116
|
// Delete file from S3 bucket
|
|
113
117
|
return true;
|
|
114
118
|
}
|
|
@@ -117,9 +121,11 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
117
121
|
|
|
118
122
|
## Subpath Exports
|
|
119
123
|
|
|
120
|
-
| Export Path
|
|
121
|
-
|
|
|
122
|
-
| `@veap/storage`
|
|
124
|
+
| Export Path | Content |
|
|
125
|
+
| ------------------------------- | -------------------------------------------------------------------------- |
|
|
126
|
+
| `@veap/storage` | `StorageService`, `StorageServiceProvider`, `LocalFileProvider`, and types |
|
|
127
|
+
| `@veap/storage/providers/local` | `LocalFileProvider` implementation |
|
|
128
|
+
| `@veap/storage/types` | `IStorageProvider`, `StorageData`, `StorageError`, and `StorageResult` |
|
|
123
129
|
|
|
124
130
|
## Documentation
|
|
125
131
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veap/storage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "File storage service and local driver for Veap",
|
|
5
5
|
"bugs": "https://github.com/veapjs/veap-storage/issues",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "vitest run"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@veap/kernel": "0.
|
|
39
|
+
"@veap/kernel": "0.2.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^22.20.2",
|