filestore

package
v3.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileHandler

type FileHandler struct {
	// LocalPath is the path on the disk where file has been stored
	LocalPath string

	// RemoteID is the objectID provided by GitLab Rails
	RemoteID string
	// RemoteURL is ObjectStore URL provided by GitLab Rails
	RemoteURL string

	// Size is the persisted file size
	Size int64

	// Name is the resource name to send back to GitLab rails.
	// It differ from the real file name in order to avoid file collisions
	Name string
	// contains filtered or unexported fields
}

FileHandler represent a file that has been processed for upload it may be either uploaded to an ObjectStore and/or saved on local path.

func SaveFileFromDisk

func SaveFileFromDisk(ctx context.Context, fileName string, opts *SaveFileOpts) (fh *FileHandler, err error)

SaveFileFromDisk open the local file fileName and calls SaveFileFromReader

func SaveFileFromReader

func SaveFileFromReader(ctx context.Context, reader io.Reader, size int64, opts *SaveFileOpts) (fh *FileHandler, err error)

SaveFileFromReader persists the provided reader content to all the location specified in opts. A cleanup will be performed once ctx is Done Make sure the provided context will not expire before finalizing upload with GitLab Rails.

func (*FileHandler) GitLabFinalizeFields

func (fh *FileHandler) GitLabFinalizeFields(prefix string) map[string]string

GitLabFinalizeFields returns a map with all the fields GitLab Rails needs in order to finalize the upload.

func (*FileHandler) MD5

func (fh *FileHandler) MD5() string

MD5 hash of the handled file

func (*FileHandler) SHA256

func (fh *FileHandler) SHA256() string

SHA256 hash of the handled file

type MD5Error

type MD5Error error

type SaveFileOpts

type SaveFileOpts struct {
	// TempFilePrefix is the prefix used to create temporary local file
	TempFilePrefix string
	// LocalTempPath is the directory where to write a local copy of the file
	LocalTempPath string
	// RemoteID is the remote ObjectID provided by GitLab
	RemoteID string
	// RemoteURL is the final URL of the file
	RemoteURL string
	// PresignedPut is a presigned S3 PutObject compatible URL
	PresignedPut string
	// PresignedDelete is a presigned S3 DeleteObject compatible URL.
	PresignedDelete string
	// Timeout it the S3 operation timeout. If 0, objectstore.DefaultObjectStoreTimeout will be used
	Timeout time.Duration
}

SaveFileOpts represents all the options available for saving a file to object store

func GetOpts

func GetOpts(apiResponse *api.Response) *SaveFileOpts

GetOpts converts GitLab api.Response to a proper SaveFileOpts

func (*SaveFileOpts) IsLocal

func (s *SaveFileOpts) IsLocal() bool

IsLocal checks if the options require the writing of the file on disk

func (*SaveFileOpts) IsRemote

func (s *SaveFileOpts) IsRemote() bool

IsRemote checks if the options requires a remote upload

type SizeError

type SizeError error

Jump to

Keyboard shortcuts

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