-
Hi, I've using XToolset and love it. Is it avilable to read xlsx from S3 ? Should I contrinute for it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @love8587 ! Thank you for your nice words ;) BackendAs far as I know, AWS provides NodeJS client which provides getting data from S3 as a 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 var AWS = require('aws-sdk');
AWS.config.update(
{
accessKeyId: ".. your key ..",
secretAccessKey: ".. your secret key ..",
}
);
var s3 = new AWS.S3();
s3.getObject(
{ Bucket: "my-bucket", Key: "my-picture.jpg" },
function (error, data) {
if (error != null) {
console.error("Failed to retrieve an object: " + error);
} else {
console.log("Loaded " + data.ContentLength + " bytes");
// 4. Build importer
const importer = buildImporterFromBuffer(data.Body)
// 5. And finally, import what you need. ;-) Good luck.
}
}
); FrontendHowever, please keep in mind. That using For front-end usages, I recommend using AWS Cloud Front, which allows us to publish S3 data as public resources. It is also an additional cost. Another solution is writing a microservice that will manage a connection with S3 and serve this file. Additionally
Bonus: with a
|
Beta Was this translation helpful? Give feedback.
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:Having this function, you can use it with AWS Node.js API
(code based on https://stackoverflow.com/a/16903730/4747028 )