Modules@robinpath/s3
s3

@robinpath/s3

0.1.4Node.jsPublic

S3-compatible object storage operations using AWS Signature V4 over HTTPS

Amazon S3

S3-compatible object storage operations using AWS SDK

Package: @robinpath/s3 | Category: Cloud Storage | Type: Integration

Authentication

s3.configure "your-credentials"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the s3 module when you need to:

  • Upload an object to S3 -- Use s3.upload to perform this operation
  • Download an object from S3 -- Use s3.download to perform this operation
  • Delete an object from S3 -- Use s3.remove to perform this operation
  • List objects in an S3 bucket -- Use s3.list to perform this operation
  • Check if an object exists in S3 -- Use s3.exists to perform this operation

Quick Reference

FunctionDescriptionReturns
configureConfigure S3 client credentials and endpointobject
uploadUpload an object to S3object
downloadDownload an object from S3object
removeDelete an object from S3object
listList objects in an S3 bucketobject
existsCheck if an object exists in S3object
copyCopy an object within or between S3 bucketsobject
moveMove an object (copy then delete source)object
presignUrlGenerate a presigned URL for an S3 objectobject
createBucketCreate a new S3 bucketobject
deleteBucketDelete an S3 bucketobject
listBucketsList all S3 bucketsobject
getMetadataGet metadata for an S3 objectobject
setAclSet the ACL for an S3 objectobject

Functions

configure

Configure S3 client credentials and endpoint

Module: s3 | Returns: object -- API response.

s3.configure
ParameterTypeRequiredDescription
optionsobjectYesConfiguration: region, endpoint, accessKeyId, secretAccessKey, sessionToken, forcePathStyle, profile

upload

Upload an object to S3

Module: s3 | Returns: object -- API response.

s3.upload
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
body`stringBuffer`Yes
optionsobjectNoOptions: contentType, metadata, profile

download

Download an object from S3

Module: s3 | Returns: object -- API response.

s3.download
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
optionsobjectNoOptions: encoding, profile

remove

Delete an object from S3

Module: s3 | Returns: object -- API response.

s3.remove
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
optionsobjectNoOptions: profile

list

List objects in an S3 bucket

Module: s3 | Returns: object -- API response.

s3.list
ParameterTypeRequiredDescription
bucketstringYesBucket name
optionsobjectNoOptions: prefix, delimiter, maxKeys, continuationToken, profile

exists

Check if an object exists in S3

Module: s3 | Returns: object -- API response.

s3.exists
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
optionsobjectNoOptions: profile

copy

Copy an object within or between S3 buckets

Module: s3 | Returns: object -- API response.

s3.copy
ParameterTypeRequiredDescription
sourceBucketstringYesSource bucket name
sourceKeystringYesSource object key
destBucketstringYesDestination bucket name
destKeystringYesDestination object key
optionsobjectNoOptions: profile

move

Move an object (copy then delete source)

Module: s3 | Returns: object -- API response.

s3.move
ParameterTypeRequiredDescription
sourceBucketstringYesSource bucket name
sourceKeystringYesSource object key
destBucketstringYesDestination bucket name
destKeystringYesDestination object key
optionsobjectNoOptions: profile

presignUrl

Generate a presigned URL for an S3 object

Module: s3 | Returns: object -- API response.

s3.presignUrl
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
optionsobjectNoOptions: expiresIn (seconds, default 3600), method (GET/PUT), contentType, profile

createBucket

Create a new S3 bucket

Module: s3 | Returns: object -- API response.

s3.createBucket
ParameterTypeRequiredDescription
bucketstringYesBucket name
optionsobjectNoOptions: profile

deleteBucket

Delete an S3 bucket

Module: s3 | Returns: object -- API response.

s3.deleteBucket
ParameterTypeRequiredDescription
bucketstringYesBucket name
optionsobjectNoOptions: profile

listBuckets

List all S3 buckets

Module: s3 | Returns: object -- API response.

s3.listBuckets
ParameterTypeRequiredDescription
optionsobjectNoOptions: profile

getMetadata

Get metadata for an S3 object

Module: s3 | Returns: object -- API response.

s3.getMetadata
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
optionsobjectNoOptions: profile

setAcl

Set the ACL for an S3 object

Module: s3 | Returns: object -- API response.

s3.setAcl
ParameterTypeRequiredDescription
bucketstringYesBucket name
keystringYesObject key
aclstringYesACL value: private, public-read, public-read-write, authenticated-read
optionsobjectNoOptions: profile

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Configure and validate result"
do
  set $result as s3.configure
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate

Retrieve all items and loop through them.

@desc "List and iterate results"
do
  set $result as s3.list
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createBucket

Create a new resource and capture the result.

set $result as s3.createBucket
print "Created: " + $result

3. Check before creating

List existing items and only create if needed.

@desc "List and create bucket"
do
  set $existing as s3.list
  if $existing == null
    s3.createBucket
    print "Item created"
  else
    print "Item already exists"
  end
enddo

4. Multi-step Amazon S3 workflow

Chain multiple s3 operations together.

@desc "Configure, upload, and more"
do
  set $r_configure as s3.configure
  set $r_upload as s3.upload
  set $r_download as s3.download
  print "All operations complete"
enddo

5. Safe configure with validation

Check results before proceeding.

@desc "Configure and validate result"
do
  set $result as s3.configure
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • dropbox -- Dropbox module for complementary functionality
  • box -- Box module for complementary functionality
  • onedrive -- OneDrive module for complementary functionality
  • google-drive -- Google Drive module for complementary functionality
  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.4latest1 months ago
Install
$ robinpath add @robinpath/s3

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.4
LicenseMIT
Unpacked Size8.5 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Category

devops