fileswap

package
v0.0.0-...-08b9edc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

type FileWriter struct {
	nocopy.NoCopy
	io.WriteCloser
	// contains filtered or unexported fields
}

func (*FileWriter) GetDownloadToken

func (fw *FileWriter) GetDownloadToken(downloadFileName string, expireIn time.Duration) (string, error)

GetDownloadToken generates a download token for downloading this file later. The downloading can be handled by the Handler.HandleDownloadRequest.

func (*FileWriter) Remove

func (fw *FileWriter) Remove()

type Handler

type Handler struct {
	nocopy.NoCopy
	// contains filtered or unexported fields
}

Handler provides a file-based data serving HTTP handler. Arbitrary data stream can be stored in the file in encrypted form temporarily, and then downloaded by the user later. As data is stored in the file, large chunk of data is supported.

Note: the download token cannot be mixed in different Handler instances.

func New

func New() *Handler

func (*Handler) HandleDownloadRequest

func (s *Handler) HandleDownloadRequest(c *gin.Context)

HandleDownloadRequest handles a gin Request for serving the file in the FS by using a download token. The file will be removed after it is successfully served to the user.

func (*Handler) NewFileWriter

func (s *Handler) NewFileWriter(tempFilePattern string) (*FileWriter, error)

NewFileWriter creates a writer for storing data into FS. A download token can be generated from the writer for downloading later. The downloading can be handled by the HandleDownloadRequest.

Jump to

Keyboard shortcuts

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