小编ddo*_*001的帖子

使用 Exceljs 将文件写入 s3 存储桶

以下脚本从 mySql 进行查询并将结果存储在本地 Excel 中。我试图解决的问题是将其保存到 S3 存储桶而不是我的计算机上。我有一些使用 AWS 的经验,可以桥接与 AWS 的连接以从 S3 存储桶读取文件,但我很难解决这个问题。谢谢!

我找到了以下代码,但无法将其与我已经编写的代码集成。

const s3 = new aws.S3(/* put your s3 configuration here */);
const stream = new Stream.PassThrough();
const workbook = new exceljs.Workbook();
// Add images of cats to workbook

workbook.xlsx.write(stream)
    .then(() => {
        return s3.upload({
            Key: PATH_IN_S3,
            Bucket: BUCKET_NAME,
            Body: stream,
            ContentType: CONTENT_TYPE_EXCEL
        }).promise();
    })
    .then(/* do whatever */)
    .catch(/* handle error */);

Here is what is currently working locally:


const reconQuery = 'SELECT T1.Database_ID, Lease_Description, SUM(BR_Current_Month_Cash …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 exceljs

1
推荐指数
1
解决办法
3852
查看次数

标签 统计

amazon-s3 ×1

exceljs ×1