upload

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchUpload

func BatchUpload(
	ctx context.Context,
	g3i client.Gen3Interface,
	furObjects []common.FileUploadRequestObject,
	workers int,
	respCh chan *http.Response,
	errCh chan error,
	bucketName string,
)

func CompleteMultipartUpload

func CompleteMultipartUpload(ctx context.Context, g3 client.Gen3Interface, key string, uploadID string, parts []fence.MultipartPart, bucketName string) error

func FormatSize

func FormatSize(size int64) string

FormatSize helps to parse a int64 size into string

func GetWaitTime

func GetWaitTime(retryCount int) time.Duration

GetWaitTime calculates exponential backoff with cap

func InitBatchUploadChannels

func InitBatchUploadChannels(numParallel int, inputSliceLen int) (int, chan *http.Response, chan error, []common.FileUploadRequestObject)

func MultipartUpload

func MultipartUpload(ctx context.Context, g3 client.Gen3Interface, req common.FileUploadRequestObject, file *os.File, showProgress bool) error

func OptimalChunkSize

func OptimalChunkSize(fileSize int64) int64

OptimalChunkSize returns a recommended chunk size for the given fileSize (in bytes). - <= 100 MB: return fileSize (use single PUT) - >100 MB and <= 1 GB: 10 MB - >1 GB and <= 10 GB: scaled between 25 MB and 128 MB - >10 GB and <= 100 GB: 256 MB - >100 GB: scaled between 512 MB and 1024 MB (1 GB) See: https://cloud.switch.ch/-/documentation/s3/multipart-uploads/#best-practices

func ProcessFilename

func ProcessFilename(logger *logs.Gen3Logger, uploadPath string, filePath string, objectId string, includeSubDirName bool, includeMetadata bool) (common.FileUploadRequestObject, error)

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

func RegisterAndUploadFile

func RegisterAndUploadFile(ctx context.Context, g3 client.Gen3Interface, drsObject *drs.DRSObject, filePath string, bucketName string, upsert bool) (*drs.DRSObject, error)

RegisterAndUploadFile orchestrates registration with Indexd and uploading via Fence. It handles checking for existing records, upsert logic, checking if file is already downloadable, and performing the upload.

func RetryFailedUploads

func RetryFailedUploads(ctx context.Context, g3 client.Gen3Interface, failedMap map[string]common.RetryObject)

RetryFailedUploads re-uploads previously failed files with exponential backoff

func Upload

func Upload(ctx context.Context, g3 client.Gen3Interface, req common.FileUploadRequestObject, showProgress bool) error

Upload is a unified catch-all function that automatically chooses between single-part and multipart upload based on file size.

func UploadSingle

func UploadSingle(ctx context.Context, g3Client client.Gen3Interface, req common.FileUploadRequestObject, showProgress bool) error

func UploadSingleFile

func UploadSingleFile(ctx context.Context, g3 client.Gen3Interface, req common.FileUploadRequestObject, showProgress bool) error

UploadSingleFile handles single-part upload with progress

Types

type FileInfo

type FileInfo struct {
	FilePath     string
	Filename     string
	FileMetadata common.FileMetadata
	ObjectId     string
}

FileInfo is a helper struct for including subdirname as filename

type PresignedURLResponse

type PresignedURLResponse struct {
	GUID string `json:"guid"`
	URL  string `json:"upload_url"`
}

func GeneratePresignedUploadURL

func GeneratePresignedUploadURL(ctx context.Context, g3 client.Gen3Interface, filename string, metadata common.FileMetadata, bucket string) (*PresignedURLResponse, error)

GeneratePresignedURL handles both Shepherd and Fence fallback

type RenamedOrSkippedFileInfo

type RenamedOrSkippedFileInfo struct {
	GUID        string
	OldFilename string
	NewFilename string
}

RenamedOrSkippedFileInfo is a helper struct for recording renamed or skipped files

type ShepherdAuthz

type ShepherdAuthz struct {
	Version       string   `json:"version"`
	ResourcePaths []string `json:"resource_paths"`
}

type ShepherdInitRequestObject

type ShepherdInitRequestObject struct {
	Filename string        `json:"file_name"`
	Authz    ShepherdAuthz `json:"authz"`
	Aliases  []string      `json:"aliases"`
	// Metadata is an encoded JSON string of any arbitrary metadata the user wishes to upload.
	Metadata map[string]any `json:"metadata"`
}

ShepherdInitRequestObject represents the payload that sends to Shepherd for getting a singlepart upload presignedURL or init a multipart upload for new object file

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