upload

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(size int64) string

FormatSize helps to parse a int64 size into string

func OptimalChunkSize

func OptimalChunkSize(fileSize int64) int64

OptimalChunkSize returns a recommended chunk size for the given fileSize (in bytes).

func ProcessFilename

func ProcessFilename(logger transfer.TransferLogger, uploadPath string, filePath string, objectId string, includeSubDirName bool, includeMetadata bool) (string, string, common.FileMetadata, error)

ProcessFilename returns an FileInfo object which has the information about the path and name to be used for upload of a file

func RegisterFile

func RegisterFile(ctx context.Context, bk UploadBackend, dc MetadataClient, drsObject *drsapi.DrsObject, filePath string, bucketName string) (*drsapi.DrsObject, error)

RegisterFile orchestrates the full registration and upload flow: 1. Build a DRS object from the local file (if not provided). 2. Register metadata with the DRS server via the provided drs.Client. 3. Upload the file content via the provided Backend.

func SeparateSingleAndMultipartUploads

func SeparateSingleAndMultipartUploads(bk interface {
	Logger() transfer.TransferLogger
}, objects []uploadRequest) ([]uploadRequest, []uploadRequest)

func Upload

func Upload(ctx context.Context, bk transfer.MultipartBackend, sourcePath, objectKey, guid, bucket string, metadata common.FileMetadata, showProgress bool, forceMultipart bool) error

Upload is now a thin wrapper around the generic EngineUploader.

func UploadSingle

func UploadSingle(ctx context.Context, bk transfer.Uploader, logger transfer.TransferLogger, sourcePath, objectKey, guid, bucket string, metadata common.FileMetadata, showProgress bool) error

UploadSingle is a compatibility shim that preserves the old entrypoint while routing the actual byte transfer through the shared engine uploader.

func UploadWithOptions

func UploadWithOptions(ctx context.Context, bk transfer.MultipartBackend, sourcePath, objectKey, guid, bucket string, metadata common.FileMetadata, showProgress bool, forceMultipart bool) error

Types

type MetadataClient

type MetadataClient interface {
	GetObject(ctx context.Context, objectID string) (drsapi.DrsObject, error)
	RegisterObjects(ctx context.Context, req drsapi.RegisterObjectsJSONRequestBody) (drsapi.N201ObjectsCreated, error)
	UpdateObjectAccessMethods(ctx context.Context, objectID string, accessMethods []drsapi.AccessMethod) (drsapi.DrsObject, error)
}

type RenamedOrSkippedFileInfo

type RenamedOrSkippedFileInfo struct {
	GUID        string
	OldFilename string
	NewFilename string
}

RenamedOrSkippedFileInfo is a helper struct for recording renamed or skipped files

type UploadBackend

type UploadBackend interface {
	transfer.Uploader
	transfer.MultipartBackend
}

type UploadConfig

type UploadConfig struct {
	BucketName        string
	NumParallel       int
	ForceMultipart    bool
	IncludeSubDirName bool
	HasMetadata       bool
	ShowProgress      bool
}

Jump to

Keyboard shortcuts

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