Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyReader = errors.New("reader is empty")
var ErrMaxDepthReached = errors.New("max archive depth reached")
Functions ¶
func HandleFile ¶
func HandleFile( ctx logContext.Context, reader io.Reader, chunkSkel *sources.Chunk, reporter sources.ChunkReporter, options ...func(*fileHandlingConfig), ) error
HandleFile orchestrates the complete file handling process for a given file. It determines the MIME type of the file, selects the appropriate handler based on this type, and processes the file. This function initializes the handling process and delegates to the specific handler to manage file extraction or processing. Errors at any stage result in an error return value. Successful handling passes the file content through a channel to be chunked and reported. The function will close the reader when it has consumed all the data.
If the skipArchives option is set to true and the detected MIME type is a known archive type, the function will skip processing the file and return nil.
func SetArchiveMaxDepth ¶ added in v3.27.0
func SetArchiveMaxDepth(depth int)
SetArchiveMaxDepth sets the maximum depth of the archive.
func SetArchiveMaxSize ¶ added in v3.27.0
func SetArchiveMaxSize(size int)
SetArchiveMaxSize sets the maximum size of the archive.
func SetArchiveMaxTimeout ¶ added in v3.27.0
SetArchiveMaxTimeout sets the maximum timeout for the archive handler.
func WithSkipArchives ¶ added in v3.63.7
func WithSkipArchives(skip bool) func(*fileHandlingConfig)
WithSkipArchives sets the skipArchives field of the fileHandlingConfig. If skip is true, the FileHandler will skip archive files.
Types ¶
type FileHandler ¶ added in v3.76.0
type FileHandler interface {
HandleFile(ctx logContext.Context, reader fileReader) (chan []byte, error)
}
FileHandler represents a handler for files. It has a single method, HandleFile, which takes a context and a fileReader as input, and returns a channel of byte slices and an error.