@webiny/api-file-manager 0.0.0-mt-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 +21 -0
- package/README.md +17 -0
- package/handlers/download/index.d.ts +3 -0
- package/handlers/download/index.js +125 -0
- package/handlers/manage/index.d.ts +3 -0
- package/handlers/manage/index.js +70 -0
- package/handlers/transform/index.d.ts +3 -0
- package/handlers/transform/index.js +96 -0
- package/handlers/transform/loaders/imageLoader.d.ts +13 -0
- package/handlers/transform/loaders/imageLoader.js +106 -0
- package/handlers/transform/loaders/index.d.ts +13 -0
- package/handlers/transform/loaders/index.js +13 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.js +51 -0
- package/handlers/transform/managers/imageManager.d.ts +9 -0
- package/handlers/transform/managers/imageManager.js +55 -0
- package/handlers/transform/managers/index.d.ts +9 -0
- package/handlers/transform/managers/index.js +13 -0
- package/handlers/transform/optimizeImage.d.ts +2 -0
- package/handlers/transform/optimizeImage.js +45 -0
- package/handlers/transform/transformImage.d.ts +9 -0
- package/handlers/transform/transformImage.js +30 -0
- package/handlers/transform/utils.d.ts +12 -0
- package/handlers/transform/utils.js +46 -0
- package/handlers/utils/createHandler.d.ts +24 -0
- package/handlers/utils/createHandler.js +68 -0
- package/handlers/utils/getEnvironment.d.ts +5 -0
- package/handlers/utils/getEnvironment.js +13 -0
- package/handlers/utils/getObjectParams.d.ts +10 -0
- package/handlers/utils/getObjectParams.js +27 -0
- package/handlers/utils/index.d.ts +3 -0
- package/handlers/utils/index.js +31 -0
- package/package.json +75 -0
- package/plugins/crud/files/validation.d.ts +3 -0
- package/plugins/crud/files/validation.js +41 -0
- package/plugins/crud/files.crud.d.ts +4 -0
- package/plugins/crud/files.crud.js +427 -0
- package/plugins/crud/settings.crud.d.ts +5 -0
- package/plugins/crud/settings.crud.js +115 -0
- package/plugins/crud/system.crud.d.ts +4 -0
- package/plugins/crud/system.crud.js +145 -0
- package/plugins/crud/utils/checkBasePermissions.d.ts +5 -0
- package/plugins/crud/utils/checkBasePermissions.js +33 -0
- package/plugins/crud/utils/createFileModel.d.ts +2 -0
- package/plugins/crud/utils/createFileModel.js +64 -0
- package/plugins/crud/utils/lifecycleEvents.d.ts +6 -0
- package/plugins/crud/utils/lifecycleEvents.js +33 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +22 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.js +42 -0
- package/plugins/definitions/FilePlugin.d.ts +133 -0
- package/plugins/definitions/FilePlugin.js +64 -0
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +34 -0
- package/plugins/definitions/FileStorageTransformPlugin.js +51 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +17 -0
- package/plugins/definitions/InstallationPlugin.d.ts +19 -0
- package/plugins/definitions/InstallationPlugin.js +40 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +17 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +17 -0
- package/plugins/graphql.d.ts +4 -0
- package/plugins/graphql.js +274 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +24 -0
- package/plugins/storage/FileStorage.d.ts +31 -0
- package/plugins/storage/FileStorage.js +95 -0
- package/plugins/storage/index.d.ts +4 -0
- package/plugins/storage/index.js +22 -0
- package/types.d.ts +357 -0
- package/types.js +5 -0
- package/utils.d.ts +4 -0
- package/utils.js +16 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
|
|
10
|
+
const emptyResolver = () => ({});
|
|
11
|
+
|
|
12
|
+
const resolve = async fn => {
|
|
13
|
+
try {
|
|
14
|
+
return new _handlerGraphql.Response(await fn());
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const plugin = {
|
|
21
|
+
type: "graphql-schema",
|
|
22
|
+
schema: {
|
|
23
|
+
typeDefs:
|
|
24
|
+
/* GraphQL */
|
|
25
|
+
`
|
|
26
|
+
type FmCreatedBy {
|
|
27
|
+
id: ID
|
|
28
|
+
displayName: String
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
input FileInput {
|
|
32
|
+
key: String
|
|
33
|
+
name: String
|
|
34
|
+
size: Int
|
|
35
|
+
type: String
|
|
36
|
+
tags: [String]
|
|
37
|
+
meta: JSON
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type UploadFileResponseDataFile {
|
|
41
|
+
name: String
|
|
42
|
+
type: String
|
|
43
|
+
size: Int
|
|
44
|
+
key: String
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type UploadFileResponseData {
|
|
48
|
+
# Contains data that is necessary for initiating a file upload.
|
|
49
|
+
data: JSON
|
|
50
|
+
file: UploadFileResponseDataFile
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type FileListMeta {
|
|
54
|
+
cursor: String
|
|
55
|
+
totalCount: Int
|
|
56
|
+
hasMoreItems: Boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type FileError {
|
|
60
|
+
code: String
|
|
61
|
+
message: String
|
|
62
|
+
data: JSON
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type FileListResponse {
|
|
66
|
+
data: [File]
|
|
67
|
+
meta: FileListMeta
|
|
68
|
+
error: FileError
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type FileResponse {
|
|
72
|
+
data: File
|
|
73
|
+
error: FileError
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type CreateFilesResponse {
|
|
77
|
+
data: [File]!
|
|
78
|
+
error: FileError
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type File {
|
|
82
|
+
id: ID
|
|
83
|
+
key: String
|
|
84
|
+
name: String
|
|
85
|
+
size: Int
|
|
86
|
+
type: String
|
|
87
|
+
src: String
|
|
88
|
+
tags: [String]
|
|
89
|
+
meta: JSON
|
|
90
|
+
createdOn: DateTime
|
|
91
|
+
createdBy: FmCreatedBy
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type FileManagerBooleanResponse {
|
|
95
|
+
data: Boolean
|
|
96
|
+
error: FileError
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type FileManagerSettings {
|
|
100
|
+
uploadMinFileSize: Number
|
|
101
|
+
uploadMaxFileSize: Number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
input FileManagerSettingsInput {
|
|
105
|
+
uploadMinFileSize: Number
|
|
106
|
+
uploadMaxFileSize: Number
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type FileManagerSettingsResponse {
|
|
110
|
+
data: FileManagerSettings
|
|
111
|
+
error: FileError
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
input FileWhereInput {
|
|
115
|
+
search: String
|
|
116
|
+
type: String
|
|
117
|
+
type_in: [String!]
|
|
118
|
+
tag: String
|
|
119
|
+
tag_in: [String!]
|
|
120
|
+
tag_and_in: [String!]
|
|
121
|
+
id_in: [ID!]
|
|
122
|
+
id: ID
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type FmQuery {
|
|
126
|
+
getFile(id: ID, where: JSON, sort: String): FileResponse
|
|
127
|
+
|
|
128
|
+
listFiles(
|
|
129
|
+
limit: Int
|
|
130
|
+
after: String
|
|
131
|
+
types: [String]
|
|
132
|
+
tags: [String]
|
|
133
|
+
ids: [ID]
|
|
134
|
+
search: String
|
|
135
|
+
where: FileWhereInput
|
|
136
|
+
): FileListResponse
|
|
137
|
+
|
|
138
|
+
listTags: [String]
|
|
139
|
+
|
|
140
|
+
# Get installed version
|
|
141
|
+
version: String
|
|
142
|
+
|
|
143
|
+
getSettings: FileManagerSettingsResponse
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
type FilesDeleteResponse {
|
|
147
|
+
data: Boolean
|
|
148
|
+
error: FileError
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type FmMutation {
|
|
152
|
+
createFile(data: FileInput!): FileResponse
|
|
153
|
+
createFiles(data: [FileInput]!): CreateFilesResponse
|
|
154
|
+
updateFile(id: ID!, data: FileInput!): FileResponse
|
|
155
|
+
deleteFile(id: ID!): FilesDeleteResponse
|
|
156
|
+
|
|
157
|
+
# Install File manager
|
|
158
|
+
install(srcPrefix: String): FileManagerBooleanResponse
|
|
159
|
+
|
|
160
|
+
upgrade(version: String!): FileManagerBooleanResponse
|
|
161
|
+
|
|
162
|
+
updateSettings(data: FileManagerSettingsInput): FileManagerSettingsResponse
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
input FilesInstallInput {
|
|
166
|
+
srcPrefix: String!
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
extend type Query {
|
|
170
|
+
fileManager: FmQuery
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
extend type Mutation {
|
|
174
|
+
fileManager: FmMutation
|
|
175
|
+
}
|
|
176
|
+
`,
|
|
177
|
+
resolvers: {
|
|
178
|
+
File: {
|
|
179
|
+
async src(file, _, context) {
|
|
180
|
+
const settings = await context.fileManager.settings.getSettings();
|
|
181
|
+
return settings.srcPrefix + file.key;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
},
|
|
185
|
+
Query: {
|
|
186
|
+
fileManager: emptyResolver
|
|
187
|
+
},
|
|
188
|
+
Mutation: {
|
|
189
|
+
fileManager: emptyResolver
|
|
190
|
+
},
|
|
191
|
+
FmQuery: {
|
|
192
|
+
getFile(_, args, context) {
|
|
193
|
+
return resolve(() => context.fileManager.files.getFile(args.id));
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
async listFiles(_, args, context) {
|
|
197
|
+
try {
|
|
198
|
+
const [data, meta] = await context.fileManager.files.listFiles(args);
|
|
199
|
+
return new _handlerGraphql.ListResponse(data, meta);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
async listTags(_, args, context) {
|
|
206
|
+
try {
|
|
207
|
+
return await context.fileManager.files.listTags(args || {});
|
|
208
|
+
} catch (error) {
|
|
209
|
+
return new _handlerGraphql.ErrorResponse(error);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
async version(_, __, context) {
|
|
214
|
+
const {
|
|
215
|
+
i18nContent,
|
|
216
|
+
tenancy,
|
|
217
|
+
fileManager
|
|
218
|
+
} = context;
|
|
219
|
+
|
|
220
|
+
if (!tenancy.getCurrentTenant() || !i18nContent.getLocale()) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return await fileManager.system.getVersion();
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
async getSettings(_, __, context) {
|
|
228
|
+
return resolve(() => context.fileManager.settings.getSettings());
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
},
|
|
232
|
+
FmMutation: {
|
|
233
|
+
async createFile(_, args, context) {
|
|
234
|
+
return resolve(() => context.fileManager.files.createFile(args.data));
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
async updateFile(_, args, context) {
|
|
238
|
+
return resolve(() => context.fileManager.files.updateFile(args.id, args.data));
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
async createFiles(_, args, context) {
|
|
242
|
+
return resolve(() => context.fileManager.files.createFilesInBatch(args.data));
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
async deleteFile(_, args, context) {
|
|
246
|
+
return resolve(async () => {
|
|
247
|
+
const file = await context.fileManager.files.getFile(args.id);
|
|
248
|
+
return await context.fileManager.storage.delete({
|
|
249
|
+
id: file.id,
|
|
250
|
+
key: file.key
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
async install(_, args, context) {
|
|
256
|
+
return resolve(() => context.fileManager.system.install({
|
|
257
|
+
srcPrefix: args.srcPrefix
|
|
258
|
+
}));
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
async upgrade(_, args, context) {
|
|
262
|
+
return resolve(() => context.fileManager.system.upgrade(args.version));
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
async updateSettings(_, args, context) {
|
|
266
|
+
return resolve(() => context.fileManager.settings.updateSettings(args.data));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var _default = plugin;
|
|
274
|
+
exports.default = _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("../types").FileManagerContext> | import("./definitions/FilePlugin").FilePlugin[] | import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("../types").FileManagerContext>)[];
|
|
2
|
+
export default _default;
|
package/plugins/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _graphql = _interopRequireDefault(require("./graphql"));
|
|
11
|
+
|
|
12
|
+
var _files = _interopRequireDefault(require("./crud/files.crud"));
|
|
13
|
+
|
|
14
|
+
var _validation = _interopRequireDefault(require("./crud/files/validation"));
|
|
15
|
+
|
|
16
|
+
var _settings = _interopRequireDefault(require("./crud/settings.crud"));
|
|
17
|
+
|
|
18
|
+
var _system = _interopRequireDefault(require("./crud/system.crud"));
|
|
19
|
+
|
|
20
|
+
var _storage = _interopRequireDefault(require("./storage"));
|
|
21
|
+
|
|
22
|
+
var _default = () => [_system.default, _settings.default, _files.default, _storage.default, _graphql.default, (0, _validation.default)()];
|
|
23
|
+
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FileManagerContext } from "../../types";
|
|
3
|
+
export declare type Args = {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
size: number;
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
keyPrefix?: string;
|
|
9
|
+
hideInFileManager?: boolean;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare type Result = Record<string, any>;
|
|
13
|
+
export interface FileStoragePlugin {
|
|
14
|
+
upload: (args: Args) => Promise<Result>;
|
|
15
|
+
delete: (args: {
|
|
16
|
+
key: string;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class FileStorage {
|
|
20
|
+
storagePlugin: FileStoragePlugin;
|
|
21
|
+
context: FileManagerContext;
|
|
22
|
+
constructor({ context }: {
|
|
23
|
+
context: any;
|
|
24
|
+
});
|
|
25
|
+
upload(args: any): Promise<Result>;
|
|
26
|
+
uploadFiles(args: any): Promise<import("../../types").File[]>;
|
|
27
|
+
delete(args: {
|
|
28
|
+
id: string;
|
|
29
|
+
key: string;
|
|
30
|
+
}): Promise<boolean>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.FileStorage = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
+
|
|
18
|
+
const storagePluginType = "api-file-manager-storage";
|
|
19
|
+
|
|
20
|
+
class FileStorage {
|
|
21
|
+
constructor({
|
|
22
|
+
context
|
|
23
|
+
}) {
|
|
24
|
+
(0, _defineProperty2.default)(this, "storagePlugin", void 0);
|
|
25
|
+
(0, _defineProperty2.default)(this, "context", void 0);
|
|
26
|
+
this.storagePlugin = context.plugins.byType(storagePluginType).pop();
|
|
27
|
+
|
|
28
|
+
if (!this.storagePlugin) {
|
|
29
|
+
throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.context = context;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async upload(args) {
|
|
36
|
+
const settings = await this.context.fileManager.settings.getSettings(); // Add file to cloud storage.
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
file: fileData
|
|
40
|
+
} = await this.storagePlugin.upload(_objectSpread(_objectSpread({}, args), {}, {
|
|
41
|
+
settings
|
|
42
|
+
}));
|
|
43
|
+
const {
|
|
44
|
+
fileManager
|
|
45
|
+
} = this.context; // Save file in DB.
|
|
46
|
+
|
|
47
|
+
return await fileManager.files.createFile(_objectSpread(_objectSpread({}, fileData), {}, {
|
|
48
|
+
meta: {
|
|
49
|
+
private: Boolean(args.hideInFileManager)
|
|
50
|
+
},
|
|
51
|
+
tags: Array.isArray(args.tags) ? args.tags : []
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async uploadFiles(args) {
|
|
56
|
+
const settings = await this.context.fileManager.settings.getSettings(); // Upload files to cloud storage.
|
|
57
|
+
|
|
58
|
+
const promises = [];
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < args.files.length; i++) {
|
|
61
|
+
const item = args.files[i];
|
|
62
|
+
promises.push(this.storagePlugin.upload(_objectSpread(_objectSpread({}, item), {}, {
|
|
63
|
+
settings
|
|
64
|
+
})));
|
|
65
|
+
} // Wait for all to resolve.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const uploadFileResponses = await Promise.all(promises);
|
|
69
|
+
const filesData = uploadFileResponses.map(response => response.file);
|
|
70
|
+
const {
|
|
71
|
+
fileManager
|
|
72
|
+
} = this.context; // Save files in DB.
|
|
73
|
+
|
|
74
|
+
return fileManager.files.createFilesInBatch(filesData);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async delete(args) {
|
|
78
|
+
const {
|
|
79
|
+
id,
|
|
80
|
+
key
|
|
81
|
+
} = args;
|
|
82
|
+
const {
|
|
83
|
+
fileManager
|
|
84
|
+
} = this.context; // Delete file from cloud storage.
|
|
85
|
+
|
|
86
|
+
await this.storagePlugin.delete({
|
|
87
|
+
key
|
|
88
|
+
}); // Delete file from the DB.
|
|
89
|
+
|
|
90
|
+
return await fileManager.files.deleteFile(id);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
exports.FileStorage = FileStorage;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
|
|
9
|
+
|
|
10
|
+
var _FileStorage = require("./FileStorage");
|
|
11
|
+
|
|
12
|
+
const fileStorageContextPlugin = new _ContextPlugin.ContextPlugin(async context => {
|
|
13
|
+
if (!context.fileManager) {
|
|
14
|
+
context.fileManager = {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
context.fileManager.storage = new _FileStorage.FileStorage({
|
|
18
|
+
context
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
var _default = fileStorageContextPlugin;
|
|
22
|
+
exports.default = _default;
|