Skip to content

[Xlsx-Import] How can I read xlsx from S3 ? #163

Answered by Siemienik
love8587 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @love8587 ! Thank you for your nice words ;)

Backend

As far as I know, AWS provides NodeJS client which provides getting data from S3 as a Buffer. So it is able to read by following function:

const buildImporterFromBuffer = (buffer) => {
  // 1. Create ExcelJS workbook instance
  const wb = new Workbook(); 
  // 2. Read the data from the Buffer
  await wb.xlsx.load(buffer);
  
  // 3. Build and return Importer
  return new Importer(wb); 
}

Having this function, you can use it with AWS Node.js API
(code based on https://stackoverflow.com/a/16903730/4747028 )

var AWS = require('aws-sdk');
AWS.config.update(
  {
    accessKeyId: ".. your key ..",
    secretAccessKey: ".. your secret key ..",

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Siemienik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #162 on March 31, 2021 12:53.