attachment

package
v3.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssembleChunks

func AssembleChunks(ctx context.Context, session *repo_model.UploadSession, allowedTypes string) (*repo_model.Attachment, error)

AssembleChunks assembles all chunks into a single file and creates an attachment

func CancelUploadSession

func CancelUploadSession(ctx context.Context, session *repo_model.UploadSession) error

CancelUploadSession cancels an upload session and cleans up

func CleanupExpiredSessions

func CleanupExpiredSessions(ctx context.Context) error

CleanupExpiredSessions is intended to be run periodically to clean up expired sessions

func CreateChunkedUploadSession

func CreateChunkedUploadSession(ctx context.Context, opts ChunkedUploadOptions) (*repo_model.UploadSession, error)

CreateChunkedUploadSession creates a new chunked upload session

func GetReceivedChunks

func GetReceivedChunks(session *repo_model.UploadSession) ([]int64, error)

GetReceivedChunks returns the list of chunk numbers that have been received

func GetTempStoragePath

func GetTempStoragePath() string

GetTempStoragePath returns the base path for chunked upload temp storage

func IsErrChecksumMismatch

func IsErrChecksumMismatch(err error) bool

IsErrChecksumMismatch returns true if the error is a checksum mismatch

func NewAttachment

func NewAttachment(ctx context.Context, attach *repo_model.Attachment, file io.Reader, size int64) (*repo_model.Attachment, error)

NewAttachment creates a new attachment object, but do not verify.

func SaveChunk

func SaveChunk(ctx context.Context, session *repo_model.UploadSession, chunkNumber int64, data io.Reader, size int64) error

SaveChunk saves a chunk to the upload session

func SaveChunkWithOptions

func SaveChunkWithOptions(ctx context.Context, session *repo_model.UploadSession, opts ChunkSaveOptions) error

SaveChunkWithOptions saves a chunk to the upload session with additional options

func UpdateAttachment

func UpdateAttachment(ctx context.Context, allowedTypes string, attach *repo_model.Attachment) error

UpdateAttachment updates an attachment, verifying that its name is among the allowed types.

func UploadAttachmentGeneralSizeLimit

func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, attach *repo_model.Attachment) (*repo_model.Attachment, error)

Types

type ChunkSaveOptions

type ChunkSaveOptions struct {
	ChunkNumber int64
	Data        io.Reader
	Size        int64
	// Checksum is the expected SHA-256 checksum of the chunk (hex-encoded)
	// If empty, checksum verification is skipped
	Checksum string
}

ChunkSaveOptions contains options for saving a chunk

type ChunkedUploadOptions

type ChunkedUploadOptions struct {
	RepoID     int64
	ReleaseID  int64
	IssueID    int64
	UploaderID int64
	FileName   string
	FileSize   int64 // -1 if unknown
	ChunkSize  int64 // 0 to use default
}

ChunkedUploadOptions contains options for creating a chunked upload session

type ErrChecksumMismatch

type ErrChecksumMismatch struct {
	Expected string
	Actual   string
}

ErrChecksumMismatch is returned when the chunk checksum doesn't match

func (ErrChecksumMismatch) Error

func (e ErrChecksumMismatch) Error() string

type UploaderFile

type UploaderFile struct {
	// contains filtered or unexported fields
}

func NewLimitedUploaderKnownSize

func NewLimitedUploaderKnownSize(r io.Reader, size int64) *UploaderFile

func NewLimitedUploaderMaxBytesReader

func NewLimitedUploaderMaxBytesReader(r io.ReadCloser, w http.ResponseWriter) *UploaderFile

Source Files

  • attachment.go
  • chunked.go

Jump to

Keyboard shortcuts

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