1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00
budibase/packages/server/src/integrations/s3.js
2021-02-19 15:07:43 +00:00

61 lines
1.2 KiB
JavaScript

const AWS = require("aws-sdk")
const SCHEMA = {
docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html",
description:
"Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.",
friendlyName: "Amazon S3",
datasource: {
region: {
type: "string",
required: true,
default: "us-east-1",
},
accessKeyId: {
type: "password",
required: true,
},
secretAccessKey: {
type: "password",
required: true,
},
},
query: {
read: {
type: "fields",
fields: {
bucket: {
type: "string",
required: true,
},
},
},
},
}
class S3Integration {
constructor(config) {
this.config = config
this.connect()
this.client = new AWS.S3()
}
async connect() {
AWS.config.update(this.config)
}
async read(query) {
const response = await this.client
.listObjects({
Bucket: query.bucket,
})
.promise()
return response.Contents
}
}
module.exports = {
schema: SCHEMA,
integration: S3Integration,
}