github-image-uploader
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Description

Upload base64 image to github by token compatible with nodejs and browser environment.

Install

with npm

npm i github-image-uploader

with cdn

<script src="https://cdn.jsdelivr.net/npm/github-image-uploader@1.1.5/dist/index.min.js"></script>

Usage

const { GhImgUploader } = require("github-image-uploader");

const uploader = new GhImgUploader(options: IOptions);
uploader.upload(uploadOptions: IUploadOptions);

IOptions

export type IOptions = {
  token: string;
  owner: string;
  repos: string;
  dir?: string;
  branch?: string;
};
Key Type Default Description
token string required, github token
owner string required, github username
repos string required, github repos name
dir string optional, upload directory, empty string means root dir. eg: sub/
branch string master optional, upload branch, by default is master branch

IUploadOptions

export type IUploadOptions = {
  base64Img: string;
  filename: string;
  filenameHandler?: "hash" | "date" | ((filename: string) => string);
};
Key Type Default Description
base64Img string required
filename string required, eg: x.jpg
filenameHandler string, function optional, "hash" or "date" will call inner built handler, you can pass custom handler by pass a function

/github-image-uploader/

    Package Sidebar

    Install

    npm i github-image-uploader

    Weekly Downloads

    14

    Version

    1.1.5

    License

    MIT

    Unpacked Size

    159 kB

    Total Files

    16

    Last publish

    Collaborators

    • alex1504