# @ssc-hermes/public-blobs

> Publicly visible images

Latest version **0.1.7** (published 2023-06-19) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @ssc-hermes/public-blobs
pnpm add @ssc-hermes/public-blobs
yarn add @ssc-hermes/public-blobs
bun add @ssc-hermes/public-blobs
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2023-06-19 |
| First published | 2023-05-07 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | nichoth |
| Maintainers | nichoth |

## Links

- npm: https://www.npmjs.com/package/@ssc-hermes/public-blobs
- Repository: https://github.com/ssc-hermes/public-blobs
- Homepage: https://github.com/ssc-hermes/public-blobs#readme
- Issues: https://github.com/ssc-hermes/public-blobs/issues
- npm.io page: https://npm.io/package/@ssc-hermes/public-blobs

## Dependencies (3)

- [cloudinary](https://npm.io/package/cloudinary.md) ^1.36.4
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^4.0.3
- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^1.3.0

## Recent versions

- 0.1.7 (latest) — 2023-06-19
- 0.1.5 — 2023-06-19
- 0.1.0 — 2023-05-11
- 0.0.3 — 2023-05-09
- 0.0.2 — 2023-05-07
- 0.0.1 — 2023-05-07
- 0.0.0 — 2023-05-07

## README

# public blobs ![tests](https://github.com/nichoth/template-ts/actions/workflows/nodejs.yml/badge.svg)

Write content addressed blobs to cloudinary, using a `blake3` hash algorithm.

## example

### write a file
Write a base64 encoded blob to cloudinary, get a hash in response.

```js
import dotenv from 'dotenv'
import { test } from 'tapzero'
import { Blobs } from '@ssc-hermes/public-blobs'
import { v2 } from 'cloudinary'
dotenv.config()
const cloudinary = v2

const config = {
    cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
    api_key: process.env.CLOUDINARY_API_KEY,
    api_secret: process.env.CLOUDINARY_API_SECRET
}

const base64file = 'data:image/png;base64,...'
cloudinary.config(config)

let blobs
test('create a cloudinary', async t => {
    blobs = Blobs(cloudinary)
    t.ok(blobs, 'blobs exists')
})

test('blobs.write', async t => {
    // `hash` is a url-safe string
    const { hash } = await blobs.write(base64file)

    t.ok(hash, 'hash exists')
    t.equal(hash, 'QyATP2PuM7EajnUt0IQlc5eRNsjQePxl9E_5YLpNGR0',
        'should return the expected hash')
})
```

### get a file
Then use [@cloudinary/url-gen](https://www.npmjs.com/package/@cloudinary/url-gen) to get the file by hash:

```js
import { scale } from "@cloudinary/url-gen/actions/resize"
import { Cloudinary } from '@cloudinary/url-gen'

const cld = new Cloudinary({
    cloud: { cloudName: 'test' },
    url: {
        secure: true // force https, set to false to force http
    }
})

const url = cld
    .image(hash)
    .resize( scale().width(100) )
    .toURL()
```

---
_Source: https://npm.io/package/@ssc-hermes/public-blobs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
