archive()

in lambda/Message_Archiver/archiver/lib/archiver.js [38:62]


  archive(rendered, endpointId, config, messageArchiveLocation) {

    if (rendered.length === 0) {return Promise.resolve('success');}

    const pathResult = this.parseS3FilePath(messageArchiveLocation);
    const html = this.generateMimeBody(rendered, endpointId, config);

    this.options.logger.log({
        level: 'info',
        message: JSON.stringify(pathResult)
    });

    return this.s3.putObject({
      Body: html,
      Bucket: pathResult.bucket,
      Key: pathResult.key
    }).promise()
      .then((results) => {
        this.options.logger.log({
            level: 'info',
            message: JSON.stringify(results)
        });
        return 'success';
      })
  };