@nathapp/nestjs-storage 2.1.5 → 3.0.0-rc.4
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 +129 -9
- package/dist/module/storage.module.js.map +1 -1
- package/dist/providers/azure-blob-storage.d.ts +22 -0
- package/dist/providers/azure-blob-storage.js +169 -0
- package/dist/providers/azure-blob-storage.js.map +1 -0
- package/dist/providers/base-storage.d.ts +3 -5
- package/dist/providers/base-storage.js +4 -1
- package/dist/providers/base-storage.js.map +1 -1
- package/dist/providers/dropbox-storage.d.ts +3 -5
- package/dist/providers/dropbox-storage.js +84 -151
- package/dist/providers/dropbox-storage.js.map +1 -1
- package/dist/providers/gcs-storage.d.ts +22 -0
- package/dist/providers/gcs-storage.js +132 -0
- package/dist/providers/gcs-storage.js.map +1 -0
- package/dist/providers/gdrive-storage.d.ts +3 -5
- package/dist/providers/gdrive-storage.js +109 -192
- package/dist/providers/gdrive-storage.js.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/local-storage.d.ts +5 -6
- package/dist/providers/local-storage.js +68 -128
- package/dist/providers/local-storage.js.map +1 -1
- package/dist/providers/oss-storage.d.ts +1 -1
- package/dist/providers/oss-storage.js +10 -4
- package/dist/providers/oss-storage.js.map +1 -1
- package/dist/providers/provider-factory.js +8 -0
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/providers/s3-base-storage.d.ts +7 -10
- package/dist/providers/s3-base-storage.js +50 -95
- package/dist/providers/s3-base-storage.js.map +1 -1
- package/dist/service/storage-service.d.ts +3 -0
- package/dist/service/storage-service.js +25 -4
- package/dist/service/storage-service.js.map +1 -1
- package/dist/types/capabilities.d.ts +15 -0
- package/dist/types/capabilities.js +3 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/clients.d.ts +216 -0
- package/dist/types/clients.js +3 -0
- package/dist/types/clients.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +28 -2
- package/dist/types/options.js +2 -0
- package/dist/types/options.js.map +1 -1
- package/dist/types/storage.d.ts +7 -2
- package/dist/util/imageUtils.js +9 -3
- package/dist/util/imageUtils.js.map +1 -1
- package/docs/20260215-fix-plan-storage.md +66 -0
- package/docs/20260215-implementation-report.md +33 -0
- package/docs/20260215-plan-storage-providers.md +207 -0
- package/docs/20260215-review-storage-postfix.md +278 -0
- package/docs/20260215-review-storage.md +284 -0
- package/docs/20260216-plan-storage-a-minus.md +41 -0
- package/docs/20260216-review-storage-postfix2.md +102 -0
- package/docs/gdrive-security.md +222 -0
- package/docs/provider-capabilities.md +448 -0
- package/package.json +8 -3
|
@@ -8,9 +8,9 @@ const dropboxFileSchema = zod_1.z.object({
|
|
|
8
8
|
'.tag': zod_1.z.union([zod_1.z.literal('file'), zod_1.z.literal('folder')]),
|
|
9
9
|
name: zod_1.z.string(),
|
|
10
10
|
id: zod_1.z.string(),
|
|
11
|
-
path_lower: zod_1.z.string(),
|
|
12
|
-
path_display: zod_1.z.string(),
|
|
13
|
-
client_modified: zod_1.z.string(),
|
|
11
|
+
path_lower: zod_1.z.string().optional(),
|
|
12
|
+
path_display: zod_1.z.string().optional(),
|
|
13
|
+
client_modified: zod_1.z.string().optional(),
|
|
14
14
|
size: zod_1.z.number().optional(),
|
|
15
15
|
});
|
|
16
16
|
const dropboxGetFilesResponseSchema = zod_1.z.object({
|
|
@@ -21,11 +21,12 @@ const dropboxGetFilesResponseSchema = zod_1.z.object({
|
|
|
21
21
|
const dropboxTokenSchema = zod_1.z.object({
|
|
22
22
|
access_token: zod_1.z.string(),
|
|
23
23
|
expires_in: zod_1.z.number(),
|
|
24
|
-
refresh_token: zod_1.z.string(),
|
|
24
|
+
refresh_token: zod_1.z.string().optional(),
|
|
25
25
|
});
|
|
26
26
|
class DropboxStorage extends base_storage_1.BaseStorage {
|
|
27
27
|
constructor(options) {
|
|
28
28
|
super(options.provider);
|
|
29
|
+
this.token = null;
|
|
29
30
|
this.credentials = {
|
|
30
31
|
clientId: options.options.clientId,
|
|
31
32
|
clientSecret: options.options.clientSecret,
|
|
@@ -33,44 +34,22 @@ class DropboxStorage extends base_storage_1.BaseStorage {
|
|
|
33
34
|
this.refreshToken = options.options.refreshToken;
|
|
34
35
|
}
|
|
35
36
|
async createFolder(path) {
|
|
36
|
-
const
|
|
37
|
-
path: 'https://api.dropboxapi.com/2/files/create_folder_v2',
|
|
38
|
-
query: {
|
|
39
|
-
path: `${path}`,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
const data = await this.makeRequest(params, dropboxFileSchema);
|
|
37
|
+
const data = await this.makeRequest('/files/create_folder_v2', { path }, dropboxFileSchema);
|
|
43
38
|
return this.parseFile(data);
|
|
44
39
|
}
|
|
45
40
|
async deleteFileOrFolder(fileId) {
|
|
46
|
-
|
|
47
|
-
path: 'https://api.dropboxapi.com/2/files/delete_v2',
|
|
48
|
-
query: {
|
|
49
|
-
path: `${fileId}`,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
await this.makeRequest(params, dropboxFileSchema);
|
|
41
|
+
await this.makeRequest('/files/delete_v2', { path: fileId }, dropboxFileSchema);
|
|
53
42
|
return true;
|
|
54
43
|
}
|
|
55
44
|
async getFileOrFolder(fileId) {
|
|
56
|
-
const
|
|
57
|
-
path: 'https://api.dropboxapi.com/2/files/get_metadata',
|
|
58
|
-
query: {
|
|
59
|
-
path: `${fileId}`,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
const data = await this.makeRequest(params, dropboxFileSchema);
|
|
45
|
+
const data = await this.makeRequest('/files/get_metadata', { path: fileId }, dropboxFileSchema);
|
|
63
46
|
return this.parseFile(data);
|
|
64
47
|
}
|
|
65
48
|
async moveFileOrFolder(fileId, newPath) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
to_path: newPath,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
const data = await this.makeRequest(params, dropboxFileSchema);
|
|
49
|
+
const data = await this.makeRequest('/files/move_v2', {
|
|
50
|
+
from_path: fileId,
|
|
51
|
+
to_path: newPath,
|
|
52
|
+
}, dropboxFileSchema);
|
|
74
53
|
return this.parseFile(data);
|
|
75
54
|
}
|
|
76
55
|
async putFile(path, data) {
|
|
@@ -87,18 +66,16 @@ class DropboxStorage extends base_storage_1.BaseStorage {
|
|
|
87
66
|
},
|
|
88
67
|
body: data,
|
|
89
68
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const dropboxFile = dropboxFileSchema.parse(json);
|
|
93
|
-
return this.parseFile(dropboxFile);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
throw new Error('Failed to upload file to Dropbox');
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new Error(`Failed to upload file to Dropbox: ${response.statusText}`);
|
|
97
71
|
}
|
|
72
|
+
const json = await response.json();
|
|
73
|
+
const dropboxFile = dropboxFileSchema.parse(json);
|
|
74
|
+
return this.parseFile(dropboxFile);
|
|
98
75
|
}
|
|
99
76
|
async readFile(fileId) {
|
|
100
77
|
const token = await this.authenticate();
|
|
101
|
-
const
|
|
78
|
+
const response = await fetch('https://content.dropboxapi.com/2/files/download', {
|
|
102
79
|
method: 'POST',
|
|
103
80
|
headers: {
|
|
104
81
|
authorization: `Bearer ${token.access_token}`,
|
|
@@ -107,65 +84,39 @@ class DropboxStorage extends base_storage_1.BaseStorage {
|
|
|
107
84
|
}),
|
|
108
85
|
'Content-Type': 'application/octet-stream',
|
|
109
86
|
},
|
|
110
|
-
};
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
fetch('https://content.dropboxapi.com/2/files/download', options)
|
|
113
|
-
.then((response) => {
|
|
114
|
-
if (!response.ok) {
|
|
115
|
-
reject(response);
|
|
116
|
-
}
|
|
117
|
-
resolve(response.body);
|
|
118
|
-
})
|
|
119
|
-
.catch((error) => {
|
|
120
|
-
reject(error);
|
|
121
|
-
});
|
|
122
87
|
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
throw new Error(`Failed to download file from Dropbox: ${response.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
return response.body;
|
|
123
92
|
}
|
|
124
93
|
async readFolder(folderId) {
|
|
125
|
-
const
|
|
126
|
-
path: folderId,
|
|
94
|
+
const data = await this.makeRequest('/files/list_folder', {
|
|
95
|
+
path: folderId === '/' ? '' : folderId,
|
|
127
96
|
include_media_info: true,
|
|
128
97
|
include_deleted: false,
|
|
129
98
|
include_has_explicit_shared_members: false,
|
|
130
99
|
include_mounted_folders: true,
|
|
131
100
|
include_non_downloadable_files: true,
|
|
132
|
-
};
|
|
133
|
-
const params = {
|
|
134
|
-
path: 'https://api.dropboxapi.com/2/files/list_folder',
|
|
135
|
-
query,
|
|
136
|
-
};
|
|
137
|
-
const data = await this.makeRequest(params, dropboxGetFilesResponseSchema);
|
|
101
|
+
}, dropboxGetFilesResponseSchema);
|
|
138
102
|
return data.entries.map((file) => this.parseFile(file));
|
|
139
103
|
}
|
|
140
|
-
renameFileOrFolder(fileId, newName) {
|
|
104
|
+
async renameFileOrFolder(fileId, newName) {
|
|
141
105
|
return this.moveFileOrFolder(fileId, newName);
|
|
142
106
|
}
|
|
143
|
-
getObjectUrl(fileId) {
|
|
107
|
+
async getObjectUrl(fileId) {
|
|
144
108
|
return this.getSignedUrl(fileId);
|
|
145
109
|
}
|
|
146
|
-
getSignedUrl(fileId) {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
return new Promise((resolve, reject) => {
|
|
154
|
-
this.makeRequest(params, zod_1.z.object({
|
|
155
|
-
link: zod_1.z.string(),
|
|
156
|
-
metadata: dropboxFileSchema,
|
|
157
|
-
}))
|
|
158
|
-
.then((data) => {
|
|
159
|
-
resolve(data.link);
|
|
160
|
-
})
|
|
161
|
-
.catch((error) => {
|
|
162
|
-
reject(error);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
110
|
+
async getSignedUrl(fileId) {
|
|
111
|
+
const result = await this.makeRequest('/files/get_temporary_link', { path: fileId }, zod_1.z.object({
|
|
112
|
+
link: zod_1.z.string(),
|
|
113
|
+
metadata: dropboxFileSchema,
|
|
114
|
+
}));
|
|
115
|
+
return result.link;
|
|
165
116
|
}
|
|
166
117
|
async streamFile(fileId, range) {
|
|
167
118
|
const token = await this.authenticate();
|
|
168
|
-
const
|
|
119
|
+
const response = await fetch('https://content.dropboxapi.com/2/files/download', {
|
|
169
120
|
method: 'POST',
|
|
170
121
|
headers: {
|
|
171
122
|
authorization: `Bearer ${token.access_token}`,
|
|
@@ -175,91 +126,73 @@ class DropboxStorage extends base_storage_1.BaseStorage {
|
|
|
175
126
|
'Content-Type': 'application/octet-stream',
|
|
176
127
|
Range: range,
|
|
177
128
|
},
|
|
178
|
-
};
|
|
179
|
-
return new Promise((resolve, reject) => {
|
|
180
|
-
fetch('https://content.dropboxapi.com/2/files/download', options)
|
|
181
|
-
.then((response) => {
|
|
182
|
-
if (!response.ok) {
|
|
183
|
-
reject(response);
|
|
184
|
-
}
|
|
185
|
-
resolve({
|
|
186
|
-
stream: response.body,
|
|
187
|
-
headers: {
|
|
188
|
-
contentType: response.headers.get('Content-Type') || '',
|
|
189
|
-
contentLength: response.headers.get('Content-Length') || '',
|
|
190
|
-
contentRange: response.headers.get('Content-Range') || '',
|
|
191
|
-
contentDisposition: response.headers.get('Content-Disposition') || '',
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
})
|
|
195
|
-
.catch((error) => {
|
|
196
|
-
reject(error);
|
|
197
|
-
});
|
|
198
129
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
130
|
+
if (!response.ok) {
|
|
131
|
+
throw new Error(`Failed to stream file from Dropbox: ${response.statusText}`);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
stream: response.body,
|
|
135
|
+
headers: {
|
|
136
|
+
contentType: response.headers.get('Content-Type') || '',
|
|
137
|
+
contentLength: response.headers.get('Content-Length') || '',
|
|
138
|
+
contentRange: response.headers.get('Content-Range') || '',
|
|
139
|
+
contentDisposition: response.headers.get('Content-Disposition') || '',
|
|
140
|
+
},
|
|
141
|
+
};
|
|
208
142
|
}
|
|
209
143
|
parseFile(file) {
|
|
210
144
|
return {
|
|
211
145
|
name: file.name,
|
|
212
|
-
path: file.path_lower,
|
|
146
|
+
path: file.path_lower || file.id,
|
|
213
147
|
size: file.size || 0,
|
|
214
148
|
mimeType: (0, util_1.getMimeType)(file.name),
|
|
215
149
|
isFolder: file['.tag'] === 'folder',
|
|
216
|
-
modifiedAt: new Date(file.client_modified),
|
|
150
|
+
modifiedAt: file.client_modified ? new Date(file.client_modified) : new Date(),
|
|
217
151
|
};
|
|
218
152
|
}
|
|
219
|
-
makeRequest(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
'Content-Type': 'application/json',
|
|
229
|
-
},
|
|
230
|
-
body: JSON.stringify(query),
|
|
231
|
-
};
|
|
232
|
-
return (0, util_1.makeRequest)(params, schema);
|
|
233
|
-
})
|
|
234
|
-
.then((data) => {
|
|
235
|
-
resolve(data);
|
|
236
|
-
})
|
|
237
|
-
.catch((error) => {
|
|
238
|
-
reject(error);
|
|
239
|
-
});
|
|
153
|
+
async makeRequest(path, payload, schema) {
|
|
154
|
+
const token = await this.authenticate();
|
|
155
|
+
const response = await fetch(`https://api.dropboxapi.com/2${path}`, {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers: {
|
|
158
|
+
Authorization: `Bearer ${token.access_token}`,
|
|
159
|
+
'Content-Type': 'application/json',
|
|
160
|
+
},
|
|
161
|
+
body: JSON.stringify(payload),
|
|
240
162
|
});
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
const errText = await response.text();
|
|
165
|
+
throw new Error(`Dropbox API Error (${path}): ${response.status} ${response.statusText} - ${errText}`);
|
|
166
|
+
}
|
|
167
|
+
const json = await response.json();
|
|
168
|
+
return schema.parse(json);
|
|
241
169
|
}
|
|
242
170
|
async authenticate() {
|
|
243
171
|
if (this.token && this.token.expires_in > Date.now()) {
|
|
244
172
|
return this.token;
|
|
245
173
|
}
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
174
|
+
const response = await fetch('https://api.dropboxapi.com/oauth2/token', {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
headers: {
|
|
177
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
178
|
+
},
|
|
179
|
+
body: new URLSearchParams({
|
|
180
|
+
grant_type: 'refresh_token',
|
|
181
|
+
refresh_token: this.refreshToken,
|
|
182
|
+
client_id: this.credentials.clientId,
|
|
183
|
+
client_secret: this.credentials.clientSecret,
|
|
184
|
+
}),
|
|
185
|
+
});
|
|
186
|
+
if (!response.ok) {
|
|
187
|
+
throw new Error(`Dropbox Auth Error: ${response.status} ${response.statusText}`);
|
|
188
|
+
}
|
|
189
|
+
const json = await response.json();
|
|
190
|
+
const tokenData = dropboxTokenSchema.parse(json);
|
|
191
|
+
this.token = {
|
|
192
|
+
...tokenData,
|
|
193
|
+
expires_in: Date.now() + (tokenData.expires_in * 1000) - 60000,
|
|
260
194
|
};
|
|
261
|
-
this.token
|
|
262
|
-
return token;
|
|
195
|
+
return this.token;
|
|
263
196
|
}
|
|
264
197
|
}
|
|
265
198
|
exports.DropboxStorage = DropboxStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropbox-storage.js","sourceRoot":"","sources":["../../lib/providers/dropbox-storage.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;
|
|
1
|
+
{"version":3,"file":"dropbox-storage.js","sourceRoot":"","sources":["../../lib/providers/dropbox-storage.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAI7C,6BAAwB;AAExB,kCAAsC;AAEtC,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzD,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACtC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,6BAA6B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;IACnC,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE;IACrB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAUH,MAAa,cAAe,SAAQ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,CAAC,YAAY;gBAChC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ;gBACpC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY;aAC/C,CAAC;SACL,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,SAAS;YACZ,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,KAAK;SAC/D,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA3OD,wCA2OC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseStorage } from './base-storage';
|
|
2
|
+
import { GCSStorageOption } from '../types/options';
|
|
3
|
+
import { IFile, PartialStream } from '../types/storage';
|
|
4
|
+
import { IStreamCapable } from '../types/capabilities';
|
|
5
|
+
export declare class GcsStorage extends BaseStorage implements IStreamCapable {
|
|
6
|
+
private readonly storage;
|
|
7
|
+
private readonly bucket;
|
|
8
|
+
private readonly bucketName;
|
|
9
|
+
constructor(options: GCSStorageOption);
|
|
10
|
+
createFolder(path: string): Promise<IFile>;
|
|
11
|
+
deleteFileOrFolder(fileId: string): Promise<boolean>;
|
|
12
|
+
getFileOrFolder(fileId: string): Promise<IFile>;
|
|
13
|
+
moveFileOrFolder(fileId: string, newPath: string): Promise<IFile>;
|
|
14
|
+
putFile(path: string, data: Buffer): Promise<IFile>;
|
|
15
|
+
readFile(fileId: string): Promise<NodeJS.ReadableStream>;
|
|
16
|
+
readFolder(folderId: string): Promise<IFile[]>;
|
|
17
|
+
renameFileOrFolder(fileId: string, newName: string): Promise<IFile>;
|
|
18
|
+
getObjectUrl(fileId: string): Promise<string>;
|
|
19
|
+
getSignedUrl(fileId: string, expires?: number): Promise<string>;
|
|
20
|
+
streamFile(fileId: string, range: string): Promise<PartialStream>;
|
|
21
|
+
private parseFile;
|
|
22
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GcsStorage = void 0;
|
|
4
|
+
const base_storage_1 = require("./base-storage");
|
|
5
|
+
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
class GcsStorage extends base_storage_1.BaseStorage {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super(options.provider);
|
|
10
|
+
const { Storage } = (0, load_package_util_1.loadPackage)('@google-cloud/storage', GcsStorage.name, () => require('@google-cloud/storage'));
|
|
11
|
+
this.bucketName = options.options.bucketName;
|
|
12
|
+
const storageOptions = {};
|
|
13
|
+
if (options.options.projectId)
|
|
14
|
+
storageOptions.projectId = options.options.projectId;
|
|
15
|
+
if (options.options.keyFilename)
|
|
16
|
+
storageOptions.keyFilename = options.options.keyFilename;
|
|
17
|
+
if (options.options.credentials)
|
|
18
|
+
storageOptions.credentials = options.options.credentials;
|
|
19
|
+
this.storage = new Storage(storageOptions);
|
|
20
|
+
this.bucket = this.storage.bucket(this.bucketName);
|
|
21
|
+
}
|
|
22
|
+
async createFolder(path) {
|
|
23
|
+
const folderPath = path.endsWith('/') ? path : `${path}/`;
|
|
24
|
+
const file = this.bucket.file(folderPath);
|
|
25
|
+
await file.save(Buffer.alloc(0));
|
|
26
|
+
return this.getFileOrFolder(folderPath);
|
|
27
|
+
}
|
|
28
|
+
async deleteFileOrFolder(fileId) {
|
|
29
|
+
const file = this.bucket.file(fileId);
|
|
30
|
+
try {
|
|
31
|
+
await file.delete();
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (e.code === 404)
|
|
36
|
+
return true;
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async getFileOrFolder(fileId) {
|
|
41
|
+
const file = this.bucket.file(fileId);
|
|
42
|
+
const [exists] = await file.exists();
|
|
43
|
+
if (exists) {
|
|
44
|
+
const [metadata] = await file.getMetadata();
|
|
45
|
+
return this.parseFile(fileId, metadata);
|
|
46
|
+
}
|
|
47
|
+
const prefix = fileId.endsWith('/') ? fileId : `${fileId}/`;
|
|
48
|
+
const [files] = await this.bucket.getFiles({ prefix, maxResults: 1 });
|
|
49
|
+
if (files.length > 0) {
|
|
50
|
+
return {
|
|
51
|
+
name: fileId.split('/').filter(Boolean).pop() || fileId,
|
|
52
|
+
path: prefix,
|
|
53
|
+
size: 0,
|
|
54
|
+
mimeType: null,
|
|
55
|
+
isFolder: true,
|
|
56
|
+
modifiedAt: new Date(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`File not found: ${fileId}`);
|
|
60
|
+
}
|
|
61
|
+
async moveFileOrFolder(fileId, newPath) {
|
|
62
|
+
const file = this.bucket.file(fileId);
|
|
63
|
+
await file.move(newPath);
|
|
64
|
+
return this.getFileOrFolder(newPath);
|
|
65
|
+
}
|
|
66
|
+
async putFile(path, data) {
|
|
67
|
+
const file = this.bucket.file(path);
|
|
68
|
+
await file.save(data, {
|
|
69
|
+
contentType: (0, util_1.getMimeType)(path) || 'application/octet-stream',
|
|
70
|
+
resumable: false,
|
|
71
|
+
});
|
|
72
|
+
return this.getFileOrFolder(path);
|
|
73
|
+
}
|
|
74
|
+
async readFile(fileId) {
|
|
75
|
+
const file = this.bucket.file(fileId);
|
|
76
|
+
return file.createReadStream();
|
|
77
|
+
}
|
|
78
|
+
async readFolder(folderId) {
|
|
79
|
+
const prefix = folderId.endsWith('/') ? folderId : `${folderId}/`;
|
|
80
|
+
const [files] = await this.bucket.getFiles({ prefix });
|
|
81
|
+
return files
|
|
82
|
+
.filter((f) => f.name !== prefix)
|
|
83
|
+
.map((f) => this.parseFile(f.name, f.metadata));
|
|
84
|
+
}
|
|
85
|
+
async renameFileOrFolder(fileId, newName) {
|
|
86
|
+
const file = this.bucket.file(fileId);
|
|
87
|
+
await file.rename(newName);
|
|
88
|
+
return this.getFileOrFolder(newName);
|
|
89
|
+
}
|
|
90
|
+
async getObjectUrl(fileId) {
|
|
91
|
+
return this.getSignedUrl(fileId);
|
|
92
|
+
}
|
|
93
|
+
async getSignedUrl(fileId, expires) {
|
|
94
|
+
const file = this.bucket.file(fileId);
|
|
95
|
+
const [url] = await file.getSignedUrl({
|
|
96
|
+
version: 'v4',
|
|
97
|
+
action: 'read',
|
|
98
|
+
expires: Date.now() + (expires || 3600) * 1000,
|
|
99
|
+
});
|
|
100
|
+
return url;
|
|
101
|
+
}
|
|
102
|
+
async streamFile(fileId, range) {
|
|
103
|
+
const file = this.bucket.file(fileId);
|
|
104
|
+
const [metadata] = await file.getMetadata();
|
|
105
|
+
const fileSize = parseInt(metadata.size, 10) || 0;
|
|
106
|
+
const parts = range.replace(/bytes=/, '').split('-');
|
|
107
|
+
const start = parseInt(parts[0], 10);
|
|
108
|
+
const end = (parts[1] && parseInt(parts[1], 10) > 0) ? parseInt(parts[1], 10) : fileSize - 1;
|
|
109
|
+
const stream = file.createReadStream({ start, end });
|
|
110
|
+
return {
|
|
111
|
+
stream,
|
|
112
|
+
headers: {
|
|
113
|
+
contentType: metadata.contentType || '',
|
|
114
|
+
contentLength: (end - start + 1).toString(),
|
|
115
|
+
contentRange: `bytes ${start}-${end}/${fileSize}`,
|
|
116
|
+
contentDisposition: 'attachment',
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
parseFile(fileId, metadata) {
|
|
121
|
+
return {
|
|
122
|
+
name: fileId.split('/').pop() || fileId,
|
|
123
|
+
path: fileId,
|
|
124
|
+
size: parseInt(metadata.size, 10) || 0,
|
|
125
|
+
mimeType: metadata.contentType || null,
|
|
126
|
+
isFolder: fileId.endsWith('/'),
|
|
127
|
+
modifiedAt: metadata.updated ? new Date(metadata.updated) : new Date(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.GcsStorage = GcsStorage;
|
|
132
|
+
//# sourceMappingURL=gcs-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcs-storage.js","sourceRoot":"","sources":["../../lib/providers/gcs-storage.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAI7C,8EAAqE;AACrE,kCAAsC;AAEtC,MAAa,UAAW,SAAQ,0BAAW;IAKzC,YAAY,OAAyB;QACnC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,+BAAW,EAAC,uBAAuB,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAElH,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;QAE7C,MAAM,cAAc,GAAQ,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS;YAAE,cAAc,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;QACpF,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW;YAAE,cAAc,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QAC1F,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW;YAAE,cAAc,CAAC,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QAE1F,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM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,SAAS,KAAK,IAAI,GAAG,IAAI,QAAQ,EAAE;gBACjD,kBAAkB,EAAE,YAAY;aACjC;SACF,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,MAAc,EAAE,QAAa;QAC7C,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM;YACvC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;YACtC,QAAQ,EAAE,QAAQ,CAAC,WAAW,IAAI,IAAI;YACtC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC9B,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;SACvE,CAAC;IACJ,CAAC;CACF;AAlJD,gCAkJC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseStorage } from './base-storage';
|
|
2
2
|
import { GDriveStorageOption } from '../types/options';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { IFile, PartialStream } from '../types/storage';
|
|
4
|
+
import { IStreamCapable } from '../types/capabilities';
|
|
5
|
+
export declare class GDriveStorage extends BaseStorage implements IStreamCapable {
|
|
5
6
|
private readonly drive;
|
|
6
7
|
constructor(options: GDriveStorageOption);
|
|
7
8
|
createFolder(path: string): Promise<IFile>;
|
|
@@ -15,9 +16,6 @@ export declare class GDriveStorage extends BaseStorage {
|
|
|
15
16
|
getObjectUrl(fileId: string): Promise<string>;
|
|
16
17
|
getSignedUrl(fileId: string): Promise<string>;
|
|
17
18
|
streamFile(fileId: string, range: string): Promise<PartialStream>;
|
|
18
|
-
getClientUploadCredential(option: ClientCredentialOptions): Promise<any>;
|
|
19
|
-
resolveClientUploadCallback(payload: any): Promise<ClientUploadCallbackResult>;
|
|
20
|
-
preprocessImage(sourceFileId: string, targetFileId: string, options: PreprocessImageOptions): Promise<PreprocessImageResult>;
|
|
21
19
|
private parseFile;
|
|
22
20
|
private readFolderRecursive;
|
|
23
21
|
}
|