# @anchan828/nest-storage

> > TODO: description

Latest version **1.0.94** (published 2024-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @anchan828/nest-storage
pnpm add @anchan828/nest-storage
yarn add @anchan828/nest-storage
bun add @anchan828/nest-storage
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.94 |
| Published | 2024-06-09 |
| First published | 2020-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | anchan828 |
| Maintainers | anchan828 |

## Links

- npm: https://www.npmjs.com/package/@anchan828/nest-storage
- Repository: https://github.com/anchan828/nest-storage
- Homepage: https://github.com/anchan828/nest-storage/tree/master/packages/storage#readme
- Issues: https://github.com/anchan828/nest-storage/issues
- npm.io page: https://npm.io/package/@anchan828/nest-storage

## Dependencies (3)

- [tmp](https://npm.io/package/tmp.md) ^0.2.1
- [compressing](https://npm.io/package/compressing.md) ^1.10.0
- [@anchan828/nest-storage-common](https://npm.io/package/@anchan828/nest-storage-common.md) ^1.0.94

## Recent versions

- 1.0.94 (latest) — 2024-06-09
- 1.0.93 — 2024-06-02
- 1.0.92 — 2024-05-26
- 1.0.91 — 2024-05-19
- 1.0.90 — 2024-05-12
- 1.0.89 — 2024-05-05
- 1.0.88 — 2024-04-28
- 1.0.87 — 2024-04-21
- 1.0.86 — 2024-04-14
- 1.0.85 — 2024-04-07
- 1.0.84 — 2024-03-31
- 1.0.83 — 2024-03-24
- 1.0.82 — 2024-03-17
- 1.0.81 — 2024-03-10
- 1.0.80 — 2024-03-03
- … 265 more at https://npm.io/package/@anchan828/nest-storage/versions

## README

# @anchan828/nest-storage

## Install

```shell
npm i @anchan828/nest-storage @anchan828/nest-storage-express
```

## Usage

You need to import 2 modules

- StorageModule
  - This is core module
- ProviderModule
  - The storage provider you want to use

```ts
@Module({
  imports: [
    StorageModule.register({
      bucket: "bucket",
      cacheDir: "path/to/cacheDir",
    }),
    LocalStorageProviderModule.register(),
  ],
})
export class AppModule {}
```

```ts
export class Service {
  constructor(private readonly service: StorageService) {}

  public async uploadFile(): Promise<void> {
    const dataPath = "local-path.txt";
    await this.service.upload(dataPath, "path/to/test.txt");
  }
}
```

## Storage providers

You can set some storage providers.

| Provider             | Pakcage                                                                                          |
| :------------------- | :----------------------------------------------------------------------------------------------- |
| Local (express)      | [@anchan828/nest-storage-express](https://www.npmjs.com/package/@anchan828/nest-storage-express) |
| Google Cloud Storage | [@anchan828/nest-storage-gcs](https://www.npmjs.com/package/@anchan828/nest-storage-gcs)         |
| Amazon S3            | [@anchan828/nest-storage-s3](https://www.npmjs.com/package/@anchan828/nest-storage-s3)           |

## Signed URL

You can get signed URL

```ts
await this.service.getSignedUrl(filename, {
  action: "upload" | "download" | "delete",
  // Milliseconds. default is 900000 = 15 mins
  expires: number,
});
// => /_signed_url/bucket/test.txt?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3Rpb24iOiJ1cGxvYWQiLCJleHBpcmVzIjo5MDAwMDAsImJ1Y2tldCI6ImJ1Y2tldCIsImZpbGVuYW1lIjoidGVzdC50eHQiLCJpYXQiOjE1NzkzMjM2MTYsImV4cCI6MTU4MDIyMzYxNn0.iJfq01VBExCvlGhKcT8hQ9d2lGTLW4miiACX3sG5HO8
```

### responseDispositionFilename

You can use the option to customize the file name when downloading file.
If you use this, `content-disposition: attachment; filename=\"${filename}\"` will be added to the header when downloading.

```ts
await this.service.getSignedUrl(filename, {
  action: "download",
  responseDispositionFilename: "changed-filename.txt",
});
```

---
_Source: https://npm.io/package/@anchan828/nest-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
