Support of AWS S3 for Node.js
Support for AWS S3 is available:
- from version 2.1.x of the com.castsoftware.nodejs extension
- from version 1.3.x of the com.castsoftware.typescript extension.
Objects
Icon | Description |
---|---|
Node.js S3 Region | |
Node.js S3 Bucket |
Links
Link Type | Function |
---|---|
No Link | createBucket |
callLink | createMultipartUpload createPresignedPost abortMultipartUpload completeMultipartUpload deleteBucketAnalyticsConfiguration deleteBucketCors deleteBucketEncryption deleteBucketInventoryConfiguration deleteBucketLifecycle deleteBucketMetricsConfiguration deleteBucketPolicy deleteBucketReplication deleteBucketTagging deleteBucketWebsite deleteObjectTagging deletePublicAccessBlock getBucketAccelerateConfiguration getBucketAcl getBucketAnalyticsConfiguration getBucketCors getBucketEncryption getBucketInventoryConfiguration getBucketLifecycle getBucketLifecycleConfiguration getBucketLocation getBucketLogging getBucketMetricsConfiguration getBucketNotification getBucketNotificationConfiguration getBucketPolicy getBucketPolicyStatus getBucketReplication getBucketTagging getBucketVersioning getBucketWebsite getObjectAcl getObjectLegalHold getObjectLockConfiguration getObjectRetention getObjectTagging getPublicAccessBlock getSignedUrl listBuckets listBucketAnalyticsConfigurations listBucketInventoryConfigurations listBucketMetricsConfigurations listMultipartUploads listObjectVersions listParts putBucketLogging putBucketAnalyticsConfiguration putBucketLifecycleConfiguration putBucketMetricsConfiguration putBucketNotification putBucketNotificationConfiguration putBucketPolicy putBucketReplication putBucketRequestPayment putBucketTagging putBucketVersioning putObjectAcl putObjectLegalHold putObjectLockConfiguration putObjectRetention putObjectTagging putPublicAccessBlock putBucketAccelerateConfiguration putBucketAcl putBucketCors putBucketEncryption putBucketInventoryConfiguration putBucketLifecycle upload uploadPart uploadPartCopy |
useInsertLink | putObject |
useDeleteLink | deleteBucket deleteObject deleteObjects |
useSelectLink | getObject getObjectTorrent listObjects listObjectsV2 |
useUpdateLink | putBucketLogging putBucketAnalyticsConfiguration |
Code samples
This code will create a S3 Bucket named “MyBucket” on an AWS server in region “REGION” and puts an object in it:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create S3 service object
s3 = new AWS.S3({apiVersion: '2006-03-01'});
// Create the parameters for calling createBucket
var bucketParams = {
Bucket : "MyBucket",
ACL : 'public-read'
};
// call S3 to create the bucket
s3.createBucket(bucketParams, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Location);
}
});
params = {
// ...
Bucket: "MyBucket"
};
s3.putObject(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});