1.2.0 • Published 11 months ago

s3b v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

s3b

s3b is a powerful and user-friendly client designed to interact with the s3b-server, a self-hosted S3-compatible storage solution. This client facilitates seamless communication with the server, enabling efficient data storage, retrieval, and management within self-hosted S3 buckets. With an intuitive interface and robust functionality, s3b simplifies the process of handling S3 operations, making it an ideal tool for developers and organizations utilizing self-hosted S3 storage systems.

Installation

Install the s3b package

npm install s3b

For s3b-server Installation go through this docs.

Usage

First of all make a config file for s3b & export bucket instance from it.

// s3b.config.js

import { Bucket } from 's3b'

const bucket = new Bucket({
    baseURL: 'YOUR_s3b-server_HOST_NAME', // Ex: https://cdn.example.com
    bucketId: 'YOUR_BUCKET_ID',
    apiKey: 'YOUR_API_KEY',
    apiSecret: 'YOUR_API_SECRET_KEY',
})

export {bucket}

Now bucket instance can be used wherever it needed. Suppose, here we are using it to store user avatar, in user controller of your express app.

// user.controller.js

import { bucket } from '/path/to/s3b.config.js'

...
const avatar = req.file
const downloadUrl = await bucket.uploadFile('/user/avatar/user-1.png', avatar)
...

Other Bucket Methods

MethodParamsDescription
uploadFilefilePath, filefilePath is the final destination of file on the server with file name (path/to/file/avt-user-9877.png). And the file is the file object got from multer.
uploadManyFiledirPath, filesdirPath is the target dir on server. files are file objects same as uploadFile.
deleteFiledownloadUrlURL of the target file
isExistdownloadUrlURL of the target file
Copysource, destinationBoth path are relative path from bucket
Movesource, destinationBoth path are relative path from bucket
readDirdirTarget directory path to list all files & dirs.
makeDirdirCreate new directory recursively

Contributing

Thank you for investing your time in contributing to our project! Whether it's a bug report, new feature, correction, or additional documentation, we greatly value feedback and contributions from our community. Any contribution you make will be reflected on github.com/CodingSamrat/s3b.

Contributions to s3b are welcome! Here's how to get started:

  • Open an issue or find for related issues to start a discussion around a feature idea or a bug.
  • Fork the repository on GitHub.
  • Create a new branch of the master branch and start making your changes.
  • Make a meaning-full commit.
  • Write a test, which shows that the bug is fixed or the feature works as expected.
  • Send a pull request and wait until it gets merged and published.
1.2.0

11 months ago

1.1.0

11 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago