# filein

> filein API (https://filein.io)

Latest version **1.4.0** (published 2020-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install filein
pnpm add filein
yarn add filein
bun add filein
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2020-12-23 |
| First published | 2020-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 53.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ken Mueller |
| Maintainers | kenmueller |

## Links

- npm: https://www.npmjs.com/package/filein
- Repository: https://github.com/kenmueller/filein-npm
- Homepage: https://github.com/kenmueller/filein-npm#readme
- Issues: https://github.com/kenmueller/filein-npm/issues
- npm.io page: https://npm.io/package/filein

## Dependencies (1)

- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.1.0

## Recent versions

- 1.4.0 (latest) — 2020-12-23
- 1.3.0 — 2020-12-23
- 1.2.3 — 2020-12-22
- 1.2.2 — 2020-12-15
- 1.2.1 — 2020-12-15
- 1.2.0 — 2020-12-15
- 1.1.0 — 2020-12-13
- 1.0.0 — 2020-06-25

## README

# [filein](https://filein.io) API

## Install

```bash
npm i filein
```

## Table of Contents

### Models

- [User](#user)
- [File](#file)

### Methods

- [Upload](#upload)
- [Get File](#get-file)
- [Get User](#get-user)

## Models

### User

```ts
interface User {
	id: string
	slug: string
	name: string
	files: number
	comments: number
}
```

### File

```ts
interface File {
	id: string
	name: string
	type: string
	size: number
	owner: string | null
	comments: number
	uploaded: Date
	public: boolean
	link: string
	url: string
	secureUrl: string
}
```

## Methods

### Upload

#### Definition

```ts
interface UploadOptions {
	name: string
	type: string
	public: boolean
	data: Buffer
}

function upload(options: UploadOptions): Promise<File>
```

#### Example

```js
const { upload } = require('filein')
const { readFileSync } = require('fs')
const { join } = require('path')

const file = await upload({
	name: 'me.png',
	type: 'image/png',
	public: false,
	data: readFileSync(join(__dirname, 'me.png'))
})

console.log(file)
```

### Get File

#### Definition

```ts
function getFile(id: string): Promise<File | null>
```

#### Example

```js
const { getFile } = require('filein')

console.log(await getFile('EMppZ8g3Fu.jpg'))
```

### Get User

#### Definition

```ts
// Faster
function getUserFromId(id: string): Promise<User | null>

// Slower
function getUserFromSlug(slug: string): Promise<User | null>
```

#### Example

```js
const { getUserFromId, getUserFromSlug } = require('filein')

console.log(await getUserFromId('R61liLnxF4bojbAtmjgtsSl9PMt2'))
console.log(await getUserFromSlug('ken-mueller'))
```

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