gofs

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

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

gofs

GitHub tag (latest SemVer) Tests CodeQL Analysis Go Report Card Go Reference License

File upload server based on golang.

Features

  • Ability to use as a library or as a standalone server. [WIP]
  • Upload single file to S3-compatible storage.
  • Multi-part upload to S3-compatible storage.
  • Universal upload HTTP handler, which can be used for single or multi-part upload. [WIP]
TODO
  • Upload multiple files to S3-compatible storage.
  • Redis DB adapter for multi-part upload.
  • Websocket transport for multi-part upload.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = errors.New("not found")
	ErrAlreadyExists     = errors.New("already exists")
	ErrFileKeyEmpty      = errors.New("file uploading key cannot be empty")
	ErrInvalidTotalParts = errors.New("total parts must be greater than zero and not more than 10000")
)

Predefined errors.

Functions

This section is empty.

Types

type CompletedPart

type CompletedPart interface {
	PartNumber() int64
	ETag() string
}

CompletedPart represents a part of a multipart upload.

type DB

type DB interface {
	// CreateUpload creates a new multipart upload.
	CreateUpload(key string, uploadID string, totalParts int64) error

	// AddPart adds a new part to the multipart upload.
	AddPart(key string, partNumber int64, etag string) error

	// CompleteUpload completes the multipart upload.
	CompleteUpload(key string) error

	// AbortUpload aborts the multipart upload.
	AbortUpload(key string) error

	// GetUploadID returns the upload ID for the given key.
	GetUploadID(key string) (string, error)

	// GetParts returns the parts for the given key.
	GetParts(key string) ([]CompletedPart, error)

	// GetStatus returns the status of the given key.
	GetStatus(key string) (UploadStatus, error)
}

DB is the interface for the storage database. The database is used to store the status of multipart uploads.

func NewInMemoryDB

func NewInMemoryDB() DB

NewInMemoryDB creates a new in-memory database.

type UploadStatus

type UploadStatus interface {
	IsCompleted() bool
	TotalParts() int64
	CompletedPartsNum() int64
}

UploadStatus represents the status of a multipart upload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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