# pipe-s3-api

> S3 API for Pipe

Latest version **0.0.13** (published 2023-02-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install pipe-s3-api
pnpm add pipe-s3-api
yarn add pipe-s3-api
bun add pipe-s3-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2023-02-15 |
| First published | 2023-02-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 23.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | TangleHub |
| Maintainers | checkkmate |

## Links

- npm: https://www.npmjs.com/package/pipe-s3-api
- Repository: https://github.com/Tanglehub/S3-API
- Homepage: https://github.com/Tanglehub/S3-API.git#readme
- Issues: https://github.com/Tanglehub/S3-API.git/issues
- npm.io page: https://npm.io/package/pipe-s3-api

## Dependencies (3)

- [xor-crypt](https://npm.io/package/xor-crypt.md) ^1.1.1
- [crypto-xor](https://npm.io/package/crypto-xor.md) ^2.1.0
- [utf8-encode](https://npm.io/package/utf8-encode.md) ^1.0.0

## Recent versions

- 0.0.13 (latest) — 2023-02-15
- 0.0.121 — 2023-02-15
- 0.0.12 — 2023-02-13
- 0.0.11 — 2023-02-13
- 0.0.1 — 2023-02-13

## README

# PIPE S3 API

##### To Include PIPE S3 API
```
const PIPE_S3 = require("pipe-s3-api");`

let s3 = new PIPE_S3({
  accessKeyId: HUBCLOUD_API_KEY,
  secretAccessKey: PIPE_SEED
});
```

Right now, three basic functions have been implemented
- `upload()`
- `getObject()`
- `listObjects()`

#### Example Usage
```
const { randomBytes } = require('crypto');
const PIPE_S3 = require("pipe-s3-api");

let s3 = new PIPE_S3({
  accessKeyId: "tanglehub_jIqWO70qVocBEV6awZX3GehESstQH5a9",
  secretAccessKey: "a52fa8bda1caec76458db951b4c0911fb53172044547432d78264a0b4235a58b",
});

async function uploadFile(bucketName, fileName, fileContent) {
  const params = {
    Bucket: bucketName,
    Key: fileName,
    Body: fileContent
  };

  try {
    return await s3.upload(params);
  } catch (err) {
    console.error(`Error uploading file: ${err}`);
  }
}


async function downloadFile(bucketName, fileName) {
  const params = {
    Bucket: bucketName,
    Key: fileName
  };

  try {
    return await s3.getObject(params);
  } catch (err) {
    console.error(`Error downloading file: ${err}`);
  }
}


async function listFiles(bucketName) {
  const params = {
    Bucket: bucketName
  };

  try {
    const response = await s3.listObjects(params);
    console.log("Files in bucket");
    response.Contents.forEach(file => console.log(file.Key));
  } catch (err) {
    console.error(`Error listing files: ${err}`);
  }
}


async function test() {
  const buck = "Tes Bucket Name";

  let res = await s3.setBucket(buck); //Required Call

  if (!res) {
    console.log("Could not initiate pipe");
    return
  }

  let contents = randomBytes(1024);
  let fileName = "test.hello";
  res = await uploadFile(buck, fileName, contents);
  console.log("Upload result: ", res);
  console.log("Listing files");
  res = await listFiles(buck);
  res = await downloadFile(buck, fileName);
  console.log("Download result: ", res);
}

test()
```

---
_Source: https://npm.io/package/pipe-s3-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
