upload

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package upload encapsulates prepping an image for sending to discord, and actually uploading it there.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient added in v0.11.1

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type State added in v0.12.0

type State string
const (
	StatePending   State = "Pending"   // waiting for decision to upload (could be edited)
	StateQueued    State = "Queued"    // ready for upload
	StateUploading State = "Uploading" // uploading
	StateComplete  State = "Complete"  // finished successfully
	StateFailed    State = "Failed"    // failed
	StateSkipped   State = "Skipped"   // user did not want to upload
)

type Upload

type Upload struct {
	Id         int32     `json:"id"`
	UploadedAt time.Time `json:"uploaded_at"`

	OriginalFilename string `json:"original_file"` // path on the local disk
	MarkedUpFilename string `json:"markedup_file"` // a temporary file, if the user did some markup

	Url string `json:"url"` // url on the discord CDN

	Width  int `json:"width"`
	Height int `json:"height"`

	State State `json:"state"`

	Client HTTPClient `json:"-"`
	// contains filtered or unexported fields
}

func (*Upload) RemoveMarkupTempFile added in v0.12.0

func (u *Upload) RemoveMarkupTempFile()

type Uploader

type Uploader struct {
	Uploads []*Upload `json:"uploads"`
	Lock    sync.Mutex
}

func NewUploader

func NewUploader() *Uploader

func (*Uploader) AddFile

func (u *Uploader) AddFile(file string, conf config.Watcher)

func (*Uploader) Upload

func (u *Uploader) Upload()

Upload uploads any files that have not yet been uploaded

func (*Uploader) UploadById added in v0.12.0

func (u *Uploader) UploadById(id int32) *Upload

Jump to

Keyboard shortcuts

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