cloudupload

package module
v0.0.0-...-d0d892b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2022 License: MIT Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Cloud Upload

Upload files to multiple Cloud Storage in parallel. Automatically apply for ssl certificate with your domain.

Install via nami
$ nami install cloudupload

or download from releases or go get github.com/txthinking/cloudupload/cli/cloudupload or embed lib go get github.com/txthinking/cloudupload

Usage
NAME:
   Cloud Upload - Upload files to multiple cloud storage in parallel

USAGE:
   main [global options] command [command options] [arguments...]

VERSION:
   20200411

AUTHOR:
   Cloud <cloud@txthinking.com>

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d                       Enable debug, more logs (default: false)
   --debugListen value, -l value     Listen address for debug (default: "127.0.0.1:6060")
   --listen value                    Listen address
   --domain value                    If domain is specified, 80 and 443 ports will be used. Listen address is no longer needed
   --maxBodySize value               Max size of http body, M (default: 0)
   --timeout value                   Read timeout, write timeout x2, idle timeout x20, s (default: 0)
   --origin value                    Allow origins for CORS, can repeat more times. like https://google.com
   --enableLocal                     Enable local store (default: false)
   --localStorage value              Local directory path
   --enableGoogle                    Enable google store (default: false)
   --googleServiceAccountFile value  Google service account file
   --googleBucket value              Google bucket name
   --enableAliyun                    Enable aliyun OSS (default: false)
   --aliyunAccessKeyID value         Aliyun access key id
   --aliyunAccessKeySecret value     Aliyun access key secret
   --aliyunEndpoint value            Aliyun endpoint, like: https://oss-cn-shanghai.aliyuncs.com
   --aliyunBucket value              Aliyun bucket name
   --enableTencent                   Enable Tencent (default: false)
   --tencentSecretId value           Tencent secret id
   --tencentSecretKey value          Tencent secret key
   --tencentHost value               domain
   --help, -h                        show help (default: false)
   --version, -v                     print the version (default: false)

COPYRIGHT:
   https://github.com/txthinking/cloudupload
Upload
Request
  • Method: POST
  • Header:
    • Accept: application/json or text/plain
    • Content-Type: application/octet-stream, application/base64 or multipart/form-data... with file field
    • X-File-Name: full file name with suffix, only required when Content-Type is application/octet-stream or application/base64
  • Body: binary file content, base64 encoded file content or multipart form data
Response
  • Status Code: 200
    • Content-Type: application/json or text/plain; charset=utf-8
    • Body: { "file": "file path" } or file path
  • Status Code: !200
    • Content-Type: text/plain; charset=utf-8
    • Body: error message
Example
$ curl -H 'Content-Type: application/octet-stream' -H 'X-File-Name: Angry.png' --data-binary @Angry.png https://yourdomain.com
vbpovzsdzbxu/Angry.png

$ curl -F 'file=@Angry.png' https://yourdomain.com
vbpovzsdzbxu/Angry.png

Author

A project by txthinking

License

Licensed under The MIT License

Documentation

Index

Constants

View Source
const (
	SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	BASE    = int64(len(SYMBOLS))
)

Variables

This section is empty.

Functions

func FromShort

func FromShort(input string) int64

Decodes a string given in our encoding and returns the decimal integer.

func Name

func Name(r *http.Request) string

func ToShort

func ToShort(number int64) string

encodes a number into our *base* representation

Types

type Aliyun

type Aliyun struct {
	AccessKeyID     string
	AccessKeySecret string
	Endpoint        string
	Bucket          string
}

func (*Aliyun) Save

func (a *Aliyun) Save(name string, r io.Reader) error

type Google

type Google struct {
	ServiceAccountFile string
	Bucket             string
}

func (*Google) Save

func (g *Google) Save(name string, r io.Reader) error

type Local

type Local struct {
	StoragePath string
}

func (*Local) Save

func (l *Local) Save(name string, r io.Reader) error

type Storer

type Storer interface {
	Save(name string, r io.Reader) error
}

type Tencent

type Tencent struct {
	SecretId  string
	SecretKey string
	Host      string
}

func (*Tencent) Authorization

func (t *Tencent) Authorization(name string, length int) (string, error)

func (*Tencent) Save

func (t *Tencent) Save(name string, r io.Reader) error

type Upload

type Upload struct {
	URL    string
	Stores []Storer
	Rate   int64
}

func (*Upload) ServeHTTP

func (u *Upload) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cli
cloudupload command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址