sendsafelyuploader

package
v0.0.0-...-af0b780 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultChunkSize int64 = 2.5 * units.MiB

DefaultChunkSize is 2.5 MB, recommended by sendsafely

Functions

func WithChunkSize

func WithChunkSize(s int64) packageOption

func WithConcurrency

func WithConcurrency(c int) packageOption

func WithRetries

func WithRetries(r uint) packageOption

Types

type File

type File struct {
	Info       *FileInfo // May not need
	Ptr        *os.File
	PartURLs   []string //URL
	UploadInfo *FileUpload
	Status     chan int
}

type FileInfo

type FileInfo struct {
	ID             string `json:"fileId"`
	Name           string `json:"fileName"`
	Size           int64  `json:"fileSize,omitempty,string"`
	Parts          int    `json:"parts"`
	Uploaded       string `json:"fileUploaded"`
	UploadedStr    string `json:"fileUploadedStr"`
	Version        string `json:"fileVersion"`
	CreatedByEmail string `json:"createdByEmail"`

	SSResponse
}

type FilePart

type FilePart struct {
	Number    int
	Offset    int64 // equal to ChunkSize * Number
	URL       string
	ChunkSize int64
}

type FileUpload

type FileUpload struct {
	Name       string `json:"filename"`
	UploadType string `json:"uploadType"`
	Parts      int    `json:"parts"`
	Part       int    `json:"part"`
	Size       int64  `json:"filesize,omitempty,string"`
}

type FinalizeInfo

type FinalizeInfo struct {
	NeedsLink bool `json:"needsLink"`

	SSResponse
}

type HostedDropzoneInfo

type HostedDropzoneInfo struct {
	Success         string   `json:"success"`
	Data            string   `json:"data"`
	Digest          string   `json:"digest"`
	IntegrationURLs []string `json:"integrationUrls"`

	SSResponse
}

type Package

type Package struct {
	Uploader    *Uploader
	Info        PackageInfo
	URL         string
	Checksum    string
	Files       []*File
	ChunkSize   int64
	Concurrency int
	Retries     uint
	// contains filtered or unexported fields
}

func (*Package) AddFileToPackage

func (p *Package) AddFileToPackage(file *os.File) (*File, error)

Given a file object, 1) Get file split parts - # of parts and chunk size 2) get upload URLs for those chunks 3) read the chunks, pipe thru encryption 4) upload the file to the URL

func (*Package) Encrypt

func (p *Package) Encrypt(unencryptedFilePart io.Reader) (*bytes.Buffer, error)

func (*Package) FinalizePackage

func (p *Package) FinalizePackage() error

FinalizePackage marks the package complete and returns a link to the package, or the error if package finalization did not succeed. Sets Package.URL on success

func (*Package) GetUploadURLs

func (p *Package) GetUploadURLs(file *File) error

Sets the upload URLs for the file parts in the provided file pointer only 25 part urls are returned - so if more than that are required, retry

func (*Package) MarkFileComplete

func (p *Package) MarkFileComplete(file *File) error

func (*Package) SubmitHostedDropzone

func (p *Package) SubmitHostedDropzone(name string, email string) error

func (*Package) UploadFileParts

func (p *Package) UploadFileParts(file *File) error

type PackageInfo

type PackageInfo struct {
	PackageID    string `json:"packageId"`
	PackageCode  string `json:"packageCode"`
	ServerSecret string `json:"serverSecret"`

	SSResponse
}

type RequestInfo

type RequestInfo struct {
	Url                string
	SsApiKey           string
	SsRequestApiTarget string
}

type SSResponse

type SSResponse struct {
	Response string `json:"response"`
	Message  string `json:"message"`
}

type UploadURL

type UploadURL struct {
	Part int    `json:"part"`
	URL  string `json:"url"`
}

type UploadUrlInfo

type UploadUrlInfo struct {
	URLS []UploadURL `json:"uploadUrls"`

	SSResponse
}

type Uploader

type Uploader struct {
	URL              string
	APIKey           string
	RequestAPITarget string
	ClientSecret     string
	Client           *http.Client
}

func CreateUploader

func CreateUploader(SSUrl, SSAPIKey, SSRequestTarget string) *Uploader

func (*Uploader) CreateDropzonePackage

func (u *Uploader) CreateDropzonePackage(options ...packageOption) (*Package, error)

Jump to

Keyboard shortcuts

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