Documentation ¶
Overview ¶
Package fileproc is the file processor that can be used in conjunction with the transformer. It downloads files to the local filesystem using the provided downloader. Probably it's a good idea to use the downloader.Client for this.
Index ¶
- Variables
- func DumpFilepath(ci *slack.Channel, f *slack.File) string
- func ExportTokenUpdateFn(token string) func(msg *slack.Message) error
- func IsValid(f *slack.File) bool
- func IsValidWithReason(f *slack.File) error
- func MattermostFilepath(_ *slack.Channel, f *slack.File) string
- func MattermostFilepathWithDir(dir string) func(*slack.Channel, *slack.File) string
- func NewExport(typ StorageType, dl Downloader) processor.Filer
- func StdFilepath(ci *slack.Channel, f *slack.File) string
- type Downloader
- type NoopDownloader
- type StorageType
- type Subprocessor
Constants ¶
This section is empty.
Variables ¶
var StorageTypeFuncs = map[StorageType]func(_ *slack.Channel, f *slack.File) string{ STmattermost: MattermostFilepath, STstandard: StdFilepath, STnone: func(_ *slack.Channel, f *slack.File) string { return "" }, }
Functions ¶
func ExportTokenUpdateFn ¶
ExportTokenUpdateFn returns a function that appends the token to every file URL in the given message.
func IsValidWithReason ¶
func MattermostFilepath ¶
MattermostFilepath returns the path to the file within the __uploads directory.
func MattermostFilepathWithDir ¶
MattermostFilepathWithDir returns the path to the file within the given directory, but it follows the mattermost naming pattern.
func NewExport ¶
func NewExport(typ StorageType, dl Downloader) processor.Filer
NewExport initialises an export file subprocessor based on the given export type. This subprocessor can be later plugged into the [expproc.Conversations] processor.
Types ¶
type Downloader ¶
type Downloader interface { // Download should download the file at the given URL and save it to the // given path. Download(fullpath string, url string) error }
Downloader is the interface that wraps the Download method.
func NewDownloader ¶
func NewDownloader(ctx context.Context, gEnabled bool, cl downloader.Downloader, fsa fsadapter.FS, lg *slog.Logger) (sdl Downloader, stop func())
NewDownloader initializes the downloader and returns it, along with a function that should be called to stop it.
type NoopDownloader ¶
type NoopDownloader struct{}
type StorageType ¶
type StorageType uint8
const ( STnone StorageType = iota STstandard STmattermost )
func (*StorageType) Set ¶
func (e *StorageType) Set(v string) error
Set translates the string value into the ExportType, satisfies flag.Value interface. It is based on the declarations generated by stringer.
func (StorageType) String ¶
func (i StorageType) String() string
type Subprocessor ¶
type Subprocessor struct {
// contains filtered or unexported fields
}
Subprocessor is the file subprocessor, that downloads files to the path returned by the filepath function. Zero value of this type is not usable.
func NewDumpSubproc ¶
func NewDumpSubproc(dl Downloader) Subprocessor
NewDumpSubproc returns a new Dump File Subprocessor.
func NewSubprocessor ¶
func NewSubprocessor(dl Downloader, fp func(ci *slack.Channel, f *slack.File) string) Subprocessor
NewSubprocessor initialises the subprocessor.
func (Subprocessor) PathUpdateFunc ¶
func (b Subprocessor) PathUpdateFunc(channelID, threadTS string, mm []slack.Message) error
PathUpdateFunc updates the path in URLDownload and URLPrivateDownload of every file in the given message slice to point to the physical downloaded file location. It can be plugged in the pipeline of Dump.