file

module
v0.0.0-...-3c82dbe Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT

README

Open Source

prepare:

upload file example

package main

import (
	"fmt"
	"os"

	"github.com/eventials/go-tus"
)

func main() {
	f, err := os.Open("./main.go")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	// create the tus client.
	client, err := tus.NewClient("http://localhost:8080/files", nil)
	if err != nil {
		panic(err)
	}
	// create an upload from a file.
	upload, err := tus.NewUploadFromFile(f)
	if err != nil {
		panic(err)
	}

	// create the uploader.
	uploader, err := client.CreateUpload(upload)
	if err != nil {
		panic(err)
	}

	// start the uploading process.
	if err := uploader.Upload(); err != nil {
		panic(err)
	}

	// link download
	fmt.Println(uploader.Url())
}

Directories

Path Synopsis
api
internal
log

Jump to

Keyboard shortcuts

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