Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenmueller/filein-npm
filein API
https://github.com/kenmueller/filein-npm
Last synced: about 2 months ago
JSON representation
filein API
- Host: GitHub
- URL: https://github.com/kenmueller/filein-npm
- Owner: kenmueller
- Created: 2020-12-13T04:55:21.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-23T10:37:58.000Z (about 4 years ago)
- Last Synced: 2024-10-26T01:04:31.207Z (2 months ago)
- Language: TypeScript
- Homepage: https://filein.io
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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
```#### 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
```#### Example
```js
const { getFile } = require('filein')console.log(await getFile('EMppZ8g3Fu.jpg'))
```### Get User
#### Definition
```ts
// Faster
function getUserFromId(id: string): Promise// Slower
function getUserFromSlug(slug: string): Promise
```#### Example
```js
const { getUserFromId, getUserFromSlug } = require('filein')console.log(await getUserFromId('R61liLnxF4bojbAtmjgtsSl9PMt2'))
console.log(await getUserFromSlug('ken-mueller'))
```