Documentation
¶
Overview ¶
file_manager.go
processing.go
upload.go
Index ¶
- Variables
- func DownloadFileFromUrl(url string, localFilePath string) (err error)
- func FileExists(filePath string) bool
- func GuessMimeType(filepath string) (string, error)
- type ClamAVPlugin
- type ExifMetadataExtractorPlugin
- type FileManager
- func (fm *FileManager) AddProcessingPlugin(name string, plugin ProcessingPlugin)
- func (aifm *FileManager) GetBaseUrl() string
- func (aifm *FileManager) GetLocalPathForFile(target FileStorageType, filename string) string
- func (aifm *FileManager) GetLocalPathOfUrl(url string) (localPath string, err error)
- func (aifm *FileManager) GetLocalTemporaryFilePath(fileName string) string
- func (aifm *FileManager) GetLocalTemporaryPath() string
- func (aifm *FileManager) GetPrivateLocalBasePath() string
- func (aifm *FileManager) GetPrivateLocalFilePath(fileName string) string
- func (aifm *FileManager) GetPublicLocalBasePath() string
- func (aifm *FileManager) GetPublicLocalFilePath(fileName string) string
- func (aifm *FileManager) GetPublicUrlForFile(localFilePath string) (url string, err error)
- func (fm *FileManager) HandleFileUpload(r io.Reader, statusCh chan<- ProcessingStatus) (*ManagedFile, error)
- func (fm *FileManager) LoadRecipes(recipesDir string) error
- func (fm *FileManager) ProcessFile(file *ManagedFile, recipeName string, statusCh chan<- ProcessingStatus)
- type FileStorageType
- type FormatConverterPlugin
- type ImageManipulationPlugin
- type ManagedFile
- func (entity *ManagedFile) EnsureFileIsLocal(fm *FileManager, target FileStorageType) (file *ManagedFile, err error)
- func (entity *ManagedFile) EnsurePublicURL(fm *FileManager) (pubUrl string, err error)
- func (entity *ManagedFile) GetFileName() string
- func (entity *ManagedFile) GetLocalFilePathWithoutFileName() string
- func (entity *ManagedFile) GetMetaData(key string) (value any)
- func (file *ManagedFile) Save() error
- func (entity *ManagedFile) SetMetaData(key string, value any)
- func (entity *ManagedFile) UpdateFilesize() int64
- func (entity *ManagedFile) UpdateMimeType() string
- type OutputFormat
- type PDFManipulationPlugin
- type PDFTextExtractorPlugin
- type ProcessingPlugin
- type ProcessingStatus
- type ProcessingStep
- type ProgressReader
- type Recipe
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRecipeNotFound = errors.New("recipe not found") ErrInvalidMimeType = errors.New("invalid MIME type") ErrInvalidFileSize = errors.New("invalid file size") ErrProcessingPluginNotFound = errors.New("processing plugin not found") )
View Source
var ErrLocalFileNotFound = errors.New("local file not found")
View Source
var ErrUrlNotMapped = errors.New("url not mapped to local file")
Functions ¶
func DownloadFileFromUrl ¶
func FileExists ¶
func GuessMimeType ¶
Types ¶
type ClamAVPlugin ¶
type ClamAVPlugin struct {
// contains filtered or unexported fields
}
func NewClamAVPlugin ¶
func NewClamAVPlugin(tcpConnection string) (*ClamAVPlugin, error)
NewClamAVPlugin creates a new ClamAVPlugin instance - only works with TCP connection tcp := viper.GetString("CLAMAV_TCP")
func (*ClamAVPlugin) Process ¶
func (p *ClamAVPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type ExifMetadataExtractorPlugin ¶ added in v0.1.2
type ExifMetadataExtractorPlugin struct{}
func (*ExifMetadataExtractorPlugin) Process ¶ added in v0.1.2
func (p *ExifMetadataExtractorPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type FileManager ¶
type FileManager struct {
// contains filtered or unexported fields
}
func NewFileManager ¶
func NewFileManager(publicLocalBasePath, privateLocalBasePath, baseUrl, tempPath string) *FileManager
func (*FileManager) AddProcessingPlugin ¶
func (fm *FileManager) AddProcessingPlugin(name string, plugin ProcessingPlugin)
func (*FileManager) GetBaseUrl ¶
func (aifm *FileManager) GetBaseUrl() string
func (*FileManager) GetLocalPathForFile ¶
func (aifm *FileManager) GetLocalPathForFile(target FileStorageType, filename string) string
func (*FileManager) GetLocalPathOfUrl ¶
func (aifm *FileManager) GetLocalPathOfUrl(url string) (localPath string, err error)
func (*FileManager) GetLocalTemporaryFilePath ¶
func (aifm *FileManager) GetLocalTemporaryFilePath(fileName string) string
func (*FileManager) GetLocalTemporaryPath ¶
func (aifm *FileManager) GetLocalTemporaryPath() string
func (*FileManager) GetPrivateLocalBasePath ¶
func (aifm *FileManager) GetPrivateLocalBasePath() string
func (*FileManager) GetPrivateLocalFilePath ¶
func (aifm *FileManager) GetPrivateLocalFilePath(fileName string) string
func (*FileManager) GetPublicLocalBasePath ¶
func (aifm *FileManager) GetPublicLocalBasePath() string
func (*FileManager) GetPublicLocalFilePath ¶
func (aifm *FileManager) GetPublicLocalFilePath(fileName string) string
func (*FileManager) GetPublicUrlForFile ¶
func (aifm *FileManager) GetPublicUrlForFile(localFilePath string) (url string, err error)
func (*FileManager) HandleFileUpload ¶
func (fm *FileManager) HandleFileUpload(r io.Reader, statusCh chan<- ProcessingStatus) (*ManagedFile, error)
func (*FileManager) LoadRecipes ¶
func (fm *FileManager) LoadRecipes(recipesDir string) error
func (*FileManager) ProcessFile ¶
func (fm *FileManager) ProcessFile(file *ManagedFile, recipeName string, statusCh chan<- ProcessingStatus)
type FileStorageType ¶
type FileStorageType string
const ( FileStorageTypePrivate FileStorageType = "private" FileStorageTypeTemp FileStorageType = "temp" FileStorageTypePublic FileStorageType = "public" )
type FormatConverterPlugin ¶ added in v0.1.2
type FormatConverterPlugin struct{}
func (*FormatConverterPlugin) Process ¶ added in v0.1.2
func (p *FormatConverterPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type ImageManipulationPlugin ¶
type ImageManipulationPlugin struct{}
func (*ImageManipulationPlugin) Process ¶
func (p *ImageManipulationPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type ManagedFile ¶
type ManagedFile struct {
FileName string `json:"fileName"`
MimeType string `json:"mimetype"`
URL string `json:"url"`
LocalFilePath string `json:"localFilePath"`
FileSize int64 `json:"fileSize"`
MetaData map[string]any `json:"metaData"`
ProcessingErrors []string `json:"processingErrors"`
Content []byte `json:"-"`
}
func (*ManagedFile) EnsureFileIsLocal ¶
func (entity *ManagedFile) EnsureFileIsLocal(fm *FileManager, target FileStorageType) (file *ManagedFile, err error)
func (*ManagedFile) EnsurePublicURL ¶
func (entity *ManagedFile) EnsurePublicURL(fm *FileManager) (pubUrl string, err error)
func (*ManagedFile) GetFileName ¶
func (entity *ManagedFile) GetFileName() string
func (*ManagedFile) GetLocalFilePathWithoutFileName ¶
func (entity *ManagedFile) GetLocalFilePathWithoutFileName() string
func (*ManagedFile) GetMetaData ¶
func (entity *ManagedFile) GetMetaData(key string) (value any)
func (*ManagedFile) Save ¶
func (file *ManagedFile) Save() error
func (*ManagedFile) SetMetaData ¶
func (entity *ManagedFile) SetMetaData(key string, value any)
func (*ManagedFile) UpdateFilesize ¶
func (entity *ManagedFile) UpdateFilesize() int64
func (*ManagedFile) UpdateMimeType ¶
func (entity *ManagedFile) UpdateMimeType() string
type OutputFormat ¶
type OutputFormat struct {
Format string `yaml:"format"`
TargetFileName string `yaml:"targetFileName"`
StorageType FileStorageType `yaml:"storageType"` // public, private, temp
}
type PDFManipulationPlugin ¶
type PDFManipulationPlugin struct{}
func (*PDFManipulationPlugin) Process ¶
func (p *PDFManipulationPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type PDFTextExtractorPlugin ¶
type PDFTextExtractorPlugin struct{}
func (*PDFTextExtractorPlugin) Process ¶
func (p *PDFTextExtractorPlugin) Process(files []*ManagedFile) ([]*ManagedFile, error)
type ProcessingPlugin ¶
type ProcessingPlugin interface {
Process(files []*ManagedFile) ([]*ManagedFile, error)
}
type ProcessingStatus ¶
type ProcessingStep ¶
type ProgressReader ¶
type ProgressReader struct {
Reader io.Reader
Size int64
Uploaded int64
StatusCh chan<- ProcessingStatus
}
type Recipe ¶
type Recipe struct {
Name string `yaml:"name"`
AcceptedMimeTypes []string `yaml:"acceptedMimeTypes"`
MinFileSize int64 `yaml:"minFileSize"`
MaxFileSize int64 `yaml:"maxFileSize"`
ProcessingSteps []ProcessingStep `yaml:"processingSteps"`
OutputFormats []OutputFormat `yaml:"outputFormats"`
}
Source Files
¶
- filemanager.go
- filemanager.models.managedfile.go
- filemanager.processing.exifmetadata.go
- filemanager.processing.formatconverter.go
- filemanager.processing.go
- filemanager.processing.pdfmanipulation.go
- filemanager.processing.pdftextextract.go
- filemanager.processor.clamav.go
- filemanager.processor.imagemanipulation.go
- filemanager.upload.go
Click to show internal directories.
Click to hide internal directories.