@@ -8,7 +8,6 @@ import { Connection } from 'cypher-query-builder';
8
8
import { intersection } from 'lodash' ;
9
9
import { Duration } from 'luxon' ;
10
10
import { Readable } from 'stream' ;
11
- import { withAddedPath } from '~/common/url.util' ;
12
11
import {
13
12
DuplicateException ,
14
13
DurationIn ,
@@ -19,8 +18,9 @@ import {
19
18
ServerException ,
20
19
Session ,
21
20
UnauthorizedException ,
22
- } from '../../common' ;
23
- import { ConfigService , ILogger , Logger } from '../../core' ;
21
+ } from '~/common' ;
22
+ import { withAddedPath } from '~/common/url.util' ;
23
+ import { ConfigService , IEventBus , ILogger , Logger } from '~/core' ;
24
24
import { FileBucket } from './bucket' ;
25
25
import {
26
26
CreateDefinedFileVersionInput ,
@@ -41,6 +41,7 @@ import {
41
41
RenameFileInput ,
42
42
RequestUploadOutput ,
43
43
} from './dto' ;
44
+ import { AfterFileUploadEvent } from './events/after-file-upload.event' ;
44
45
import { FileUrlController as FileUrl } from './file-url.controller' ;
45
46
import { FileRepository } from './file.repository' ;
46
47
import { MediaService } from './media/media.service' ;
@@ -53,6 +54,7 @@ export class FileService {
53
54
private readonly db : Connection ,
54
55
private readonly config : ConfigService ,
55
56
private readonly mediaService : MediaService ,
57
+ private readonly eventBus : IEventBus ,
56
58
@Logger ( 'file:service' ) private readonly logger : ILogger ,
57
59
) { }
58
60
@@ -225,6 +227,12 @@ export class FileService {
225
227
return await this . getDirectory ( id , session ) ;
226
228
}
227
229
230
+ async createRootDirectory (
231
+ ...args : Parameters < FileRepository [ 'createRootDirectory' ] >
232
+ ) {
233
+ return await this . repo . createRootDirectory ( ...args ) ;
234
+ }
235
+
228
236
async requestUpload ( ) : Promise < RequestUploadOutput > {
229
237
const id = await generateId ( ) ;
230
238
const url = await this . bucket . getSignedUrl ( PutObject , {
@@ -361,7 +369,11 @@ export class FileService {
361
369
// Change the file's name to match the latest version name
362
370
await this . rename ( { id : fileId , name } , session ) ;
363
371
364
- return await this . getFile ( fileId , session ) ;
372
+ const file = await this . getFile ( fileId , session ) ;
373
+
374
+ await this . eventBus . publish ( new AfterFileUploadEvent ( file ) ) ;
375
+
376
+ return file ;
365
377
}
366
378
367
379
private async validateParentNode (
0 commit comments