Documentation
¶
Index ¶
- func AssembleChunks(ctx context.Context, session *repo_model.UploadSession, allowedTypes string) (*repo_model.Attachment, error)
- func CancelUploadSession(ctx context.Context, session *repo_model.UploadSession) error
- func CleanupExpiredSessions(ctx context.Context) error
- func CreateChunkedUploadSession(ctx context.Context, opts ChunkedUploadOptions) (*repo_model.UploadSession, error)
- func GetReceivedChunks(session *repo_model.UploadSession) ([]int64, error)
- func GetTempStoragePath() string
- func IsErrChecksumMismatch(err error) bool
- func NewAttachment(ctx context.Context, attach *repo_model.Attachment, file io.Reader, size int64) (*repo_model.Attachment, error)
- func SaveChunk(ctx context.Context, session *repo_model.UploadSession, chunkNumber int64, ...) error
- func SaveChunkWithOptions(ctx context.Context, session *repo_model.UploadSession, opts ChunkSaveOptions) error
- func UpdateAttachment(ctx context.Context, allowedTypes string, attach *repo_model.Attachment) error
- func UploadAttachmentGeneralSizeLimit(ctx context.Context, file *UploaderFile, allowedTypes string, ...) (*repo_model.Attachment, error)
- type ChunkSaveOptions
- type ChunkedUploadOptions
- type ErrChecksumMismatch
- type UploaderFile
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 ¶
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 ¶
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 ¶
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