@@ -6,14 +6,13 @@ const iconv = require('iconv-lite');
6
6
const { AttachmentProcessor } = require ( '@elastic.io/component-commons-library' ) ;
7
7
const { Client } = require ( '../client' ) ;
8
8
const params = require ( '../parameters' ) ;
9
-
9
+ const { getUserAgent } = require ( '../utils/utils' ) ;
10
10
11
11
exports . process = async function ( msg , cfg ) {
12
12
const client = new Client ( this . logger , cfg ) ;
13
13
const bucketName = msg . body . bucketName ? msg . body . bucketName : cfg . bucketName ;
14
14
const { filename } = msg . body ;
15
15
16
- // const result = await client.getObjectReadStream(bucketName, filename);
17
16
const result = await client . getObjectMetadata ( bucketName , filename ) ;
18
17
19
18
if ( result . ContentLength > params . ATTACHMENT_MAX_SIZE ) {
@@ -34,9 +33,10 @@ exports.process = async function (msg, cfg) {
34
33
if ( contentType === 'application/xml' ) doc = JSON . parse ( convert . xml2json ( fileContent ) ) ;
35
34
await this . emit ( 'data' , messages . newMessageWithBody ( doc ) ) ;
36
35
} else {
37
- const readStream = client . getObjectReadStream ( bucketName , filename ) ;
38
- const results = await new AttachmentProcessor ( ) . uploadAttachment ( readStream ) ;
39
- const attachmentUrl = `${ results . config . url } ${ results . data . objectId } ?storage_type=maester` ;
36
+ const getAttachment = ( ) => client . getObjectReadStream ( bucketName , filename ) ;
37
+ const attachmentProcessor = new AttachmentProcessor ( getUserAgent ( ) , msg . id ) ;
38
+ const attachmentId = await attachmentProcessor . uploadAttachment ( getAttachment ) ;
39
+ const attachmentUrl = attachmentProcessor . getMaesterAttachmentUrlById ( attachmentId ) ;
40
40
41
41
const attachments = {
42
42
[ filename ] : {
0 commit comments