@robinpath/s3
0.1.4Node.jsPublicS3-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.uploadto perform this operation - Download an object from S3 -- Use
s3.downloadto perform this operation - Delete an object from S3 -- Use
s3.removeto perform this operation - List objects in an S3 bucket -- Use
s3.listto perform this operation - Check if an object exists in S3 -- Use
s3.existsto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
configure | Configure S3 client credentials and endpoint | object |
upload | Upload an object to S3 | object |
download | Download an object from S3 | object |
remove | Delete an object from S3 | object |
list | List objects in an S3 bucket | object |
exists | Check if an object exists in S3 | object |
copy | Copy an object within or between S3 buckets | object |
move | Move an object (copy then delete source) | object |
presignUrl | Generate a presigned URL for an S3 object | object |
createBucket | Create a new S3 bucket | object |
deleteBucket | Delete an S3 bucket | object |
listBuckets | List all S3 buckets | object |
getMetadata | Get metadata for an S3 object | object |
setAcl | Set the ACL for an S3 object | object |
Functions
configure
Configure S3 client credentials and endpoint
Module: s3 | Returns: object -- API response.
s3.configure
| Parameter | Type | Required | Description |
|---|---|---|---|
options | object | Yes | Configuration: region, endpoint, accessKeyId, secretAccessKey, sessionToken, forcePathStyle, profile |
upload
Upload an object to S3
Module: s3 | Returns: object -- API response.
s3.upload
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
body | `string | Buffer` | Yes |
options | object | No | Options: contentType, metadata, profile |
download
Download an object from S3
Module: s3 | Returns: object -- API response.
s3.download
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
options | object | No | Options: encoding, profile |
remove
Delete an object from S3
Module: s3 | Returns: object -- API response.
s3.remove
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
options | object | No | Options: profile |
list
List objects in an S3 bucket
Module: s3 | Returns: object -- API response.
s3.list
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
options | object | No | Options: prefix, delimiter, maxKeys, continuationToken, profile |
exists
Check if an object exists in S3
Module: s3 | Returns: object -- API response.
s3.exists
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
options | object | No | Options: profile |
copy
Copy an object within or between S3 buckets
Module: s3 | Returns: object -- API response.
s3.copy
| Parameter | Type | Required | Description |
|---|---|---|---|
sourceBucket | string | Yes | Source bucket name |
sourceKey | string | Yes | Source object key |
destBucket | string | Yes | Destination bucket name |
destKey | string | Yes | Destination object key |
options | object | No | Options: profile |
move
Move an object (copy then delete source)
Module: s3 | Returns: object -- API response.
s3.move
| Parameter | Type | Required | Description |
|---|---|---|---|
sourceBucket | string | Yes | Source bucket name |
sourceKey | string | Yes | Source object key |
destBucket | string | Yes | Destination bucket name |
destKey | string | Yes | Destination object key |
options | object | No | Options: profile |
presignUrl
Generate a presigned URL for an S3 object
Module: s3 | Returns: object -- API response.
s3.presignUrl
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
options | object | No | Options: expiresIn (seconds, default 3600), method (GET/PUT), contentType, profile |
createBucket
Create a new S3 bucket
Module: s3 | Returns: object -- API response.
s3.createBucket
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
options | object | No | Options: profile |
deleteBucket
Delete an S3 bucket
Module: s3 | Returns: object -- API response.
s3.deleteBucket
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
options | object | No | Options: profile |
listBuckets
List all S3 buckets
Module: s3 | Returns: object -- API response.
s3.listBuckets
| Parameter | Type | Required | Description |
|---|---|---|---|
options | object | No | Options: profile |
getMetadata
Get metadata for an S3 object
Module: s3 | Returns: object -- API response.
s3.getMetadata
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
options | object | No | Options: profile |
setAcl
Set the ACL for an S3 object
Module: s3 | Returns: object -- API response.
s3.setAcl
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
key | string | Yes | Object key |
acl | string | Yes | ACL value: private, public-read, public-read-write, authenticated-read |
options | object | No | Options: profile |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (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)
| Version | Tag | Published |
|---|---|---|
| 0.1.4 | latest | 1 months ago |
Related Modules
github
JS@robinpathv0.1.1
GitHub module for RobinPath.
bitbucket
JS@robinpathv0.1.2
Bitbucket module for RobinPath.
box
JS@robinpathv0.1.2
Box module for RobinPath.
cache
JS@robinpathv0.1.2
In-memory key-value cache with optional TTL expiration for temporary data storage
$ robinpath add @robinpath/s3
