Categorygithub.com/louis-she/simple-uploader
repository
0.0.20
Repository: https://github.com/louis-she/simple-uploader.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

Simple Uploader

Test Release

This is a simple file uploader that supports resumable file uploading. It is provided as a controller of the Gin Web Framework.

Just call Attach on gin.Engine to add the routes and we are ready to go.

import (
  ...
  "github.com/louis-she/simple-uploader/controllers"
  ...
)

r := gin.Default()

controllers.Attach(r, "/")

Clients

Only the Browser JavaScript client and Python client are provided. For Golang, see test.

All the clients expose very similar APIs.

Browser JavaScript

Installation

npm config set @louis-she:registry https://npm.pkg.github.com/
npm install @louis-she/simple-uploader

Usage

import SimpleUploader from "@louis-she/simple-uploader";

// file = ...

const uploader = new SimpleUploader(file, {
  endpoint: "/files",
  chunkSize: 10 * 1024 ** 2,  // 10 MB
  onProgress: (progress) => {
    // ...
  },
});
await uploader.upload();
const res = await uploader.checksum()
console.log(res)

For a more specific example, please see the development example main.ts

Python

Installation

pip3 install git+https://github.com/louis-she/simple-uploader#subdirectory=clients/python

Usage

from simple_uploader import SimpleUploader

su = SimpleUploader("/some/large/file/path")
su.upload()
res = su.checksum()
print(res)

Development Client

  1. Start mockserver
# in clients directory
go run ./mockserver
  1. (For JS) Start dev server
# in clients/browser_javascript
pnpm isntall
pnpm run dev

TODO

  • Concurrent slice uploading