AWS Lambda - NodeJS
Learn how to configure AWS Lambda functions for NodeJS for use with Filebase.
AWS Lambda is a service offered by Amazon Web Services that offers a serverless computing platform for creating event-driven pieces of code. Lambda automatically manages any computing resources required for the code, so there is no configuration or development environment required by the end-user.
In this guide, we’ll use Lambda for creating a PutObject function using NodeJS. This can be modified for a variety of different API requests, such as GetObject and CreateBucket, and can be used with different SDKs and Runtimes. For a list of supported SDKs and associated API request examples, check out our SDK documentation here.
Read below to learn how to configure AWS Lambda functions for NodeJS use with Filebase.




const AWS = require('aws-sdk');
const fs = require('fs');
exports.handler = async function(event, context) {
}
const s3 = new AWS.S3({
endpoint: 'https://s3.filebase.com',
region: 'us-east-1',
signatureVersion: 'v4',
accessKeyId: 'FILEBASE-ACCESS-KEY',
secretAccessKey: 'FILEBASE-SECRET-KEY',
});
fs.readFile('image.png', (err, data) => {
if (err) {
console.error(err);
return;
}
const params = {
Bucket: 'BUCKET-NAME',
Key: 'FILE-NAME.txt',
ContentType: 'image/png',
Body: data,
};
const request = s3.putObject(params);
request.on('httpHeaders', (statusCode, headers) => {
print(`CID: ${headers['x-amz-meta-cid']}`);
});
request.send();
});
Replace the following values in the code to match your configuration:
- accessKeyId: Your Filebase Access Key
- secretAccessKey: Your Filebase Secret Key
- Bucket: Your Filebase Bucket Name
- Key: The Local Path To The Object To Be Uploaded
- Content Type: The Type of Object Being Uploaded







If you have any questions, please join our Discord server, or send us an email at [email protected]
Last modified 1yr ago