Official Node.js SDK for ApexxCloud Storage Service.
npm install @apexxcloud/sdk-node
const ApexxCloud = require('@apexxcloud/sdk-node');
const storage = new ApexxCloud({
accessKey: 'your-access-key',
secretKey: 'your-secret-key',
region: 'APAC',
bucket: 'default-bucket'
});
- Simple file upload
- Multipart upload for large files
- File deletion
- Signed URL generation
- Bucket contents listing
- Error handling
- TypeScript support
const result = await storage.files.upload(
'bucket-name', // bucket name (optional if default bucket configured)
'./path/to/file.jpg', // file path
{
region: 'us-east-1', // optional
visibility: 'public' // optional, defaults to 'public'
}
);
await storage.files.delete(
'bucket-name', // bucket name (optional if default bucket configured)
'path/to/file.jpg' // file path in bucket
);
const url = await storage.files.getSignedUrl(
'bucket-name', // bucket name (optional if default bucket configured)
'path/to/file.jpg', // file path in bucket
{
expiresIn: 3600 // optional, defaults to 3600 seconds (1 hour)
}
);
const upload = await storage.files.startMultipartUpload(
'bucket-name', // bucket name (optional if default bucket configured)
'large-file.zip', // key
{
totalParts: 3, // optional, defaults to 1
mimeType: 'application/zip', // optional
visibility: 'public' // optional, defaults to 'public'
}
);
const partResult = await storage.files.uploadPart(
uploadId, // from startMultipartUpload response
1, // part number
filePartBuffer, // file part as Buffer or Stream
{
bucketName: 'bucket-name', // optional if default bucket configured
key: 'file-key', // from startMultipartUpload response
totalParts: 3 // total number of parts
}
);
await storage.files.completeMultipartUpload(
uploadId, // from startMultipartUpload response
parts, // array of completed parts
{
bucketName: 'bucket-name', // optional if default bucket configured
key: 'large-file.zip' // original filename
}
);
await storage.files.cancelMultipartUpload(
uploadId, // from startMultipartUpload response
{
bucketName: 'bucket-name', // optional if default bucket configured
key: 'file-key' // from startMultipartUpload response
}
);
const contents = await storage.bucket.listContents(
'bucket-name', // bucket name (optional if default bucket configured)
{
prefix: 'folder/', // optional, filter by prefix
page: 1, // optional, defaults to 1
limit: 20 // optional, defaults to 20
}
);
Generate pre-signed URLs for various operations:
const signedUrl = await storage.generateSignedUrl('upload', {
bucketName: 'bucket-name', // optional if default bucket configured
visibility: 'public' // optional, defaults to 'public'
});
// Other supported operations:
// - 'delete'
// - 'start-multipart'
// - 'uploadpart'
// - 'completemultipart'
// - 'cancelmultipart'
The SDK throws errors with detailed messages for various failure scenarios:
try {
await storage.files.upload('bucket-name', './file.jpg');
} catch (error) {
console.error('Operation failed:', error.message);
}
For detailed documentation, visit docs.apexxcloud.com
MIT