Documentation ¶
Overview ¶
processing.go
upload.go
Index ¶
- Constants
- Variables
- func DownloadFileFromUrl(url string, localFilePath string) (err error)
- func FileExists(filePath string) bool
- func GuessMimeType(filepath string) (string, error)
- func NID(prefix string, length int) (nid string)
- func ReplaceFileNameVariables(fileName string, file *ManagedFile) string
- type ClamAVPlugin
- type ExifMetadataExtractorPlugin
- type FileManager
- func (fm *FileManager) AddProcessingPlugin(name string, plugin ProcessingPlugin)
- func (fm *FileManager) CreateManagedFileFromFileHeader(fileHeader *multipart.FileHeader, targetStorageType FileStorageType) (*ManagedFile, error)
- func (fm *FileManager) CreateManagedFileFromPath(localPath string, targetStorageType FileStorageType) (*ManagedFile, error)
- func (fm *FileManager) CreateManagedFileFromResponseBody(filename string, responseBody io.ReadCloser, targetStorageType FileStorageType) (*ManagedFile, error)
- 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) (pubUrl string, err error)
- func (fm *FileManager) GetRecipe(name string) (Recipe, error)
- func (fm *FileManager) HandleFileUpload(r io.Reader, fileProcess *FileProcess, statusCh chan<- *FileProcess) (*ManagedFile, error)
- func (fm *FileManager) LoadRecipes(recipesDir string) error
- func (fm *FileManager) LogTo(level string, message string)
- func (fm *FileManager) ProcessFile(file *ManagedFile, recipeName string, fileProcess *FileProcess, ...)
- func (fm *FileManager) RunProcessingStep(file *ManagedFile, pluginName string, params map[string]any, ...) (*ManagedFile, error)
- type FileProcess
- type FileStorageType
- type FormatConverterPlugin
- type ImageManipulationPlugin
- type LogAdapter
- 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 ProcessingResultFile
- type ProcessingStatus
- type ProcessingStep
- type ProgressReader
- type Recipe
Constants ¶
View Source
const FILE_PROCESS_ID_LENGTH = 16
View Source
const FILE_PROCESS_ID_PREFIX = "FP"
View Source
const Version = "0.5.1"
Variables ¶
View Source
var ( ErrLocalFileNotFound = errors.New("local file not found") ErrUrlNotMapped = errors.New("url not mapped to local file") )
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 (
ErrNilResponseBody = errors.New("response body is nil")
)
Functions ¶
func DownloadFileFromUrl ¶
func FileExists ¶
func GuessMimeType ¶
func ReplaceFileNameVariables ¶ added in v0.4.3
func ReplaceFileNameVariables(fileName string, file *ManagedFile) string
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, fileProcess *FileProcess) ([]*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, fileProcess *FileProcess) ([]*ManagedFile, error)
type FileManager ¶
type FileManager struct {
// contains filtered or unexported fields
}
func NewFileManager ¶
func NewFileManager(publicLocalBasePath, privateLocalBasePath, baseUrl, tempPath string, logger LogAdapter) *FileManager
func (*FileManager) AddProcessingPlugin ¶
func (fm *FileManager) AddProcessingPlugin(name string, plugin ProcessingPlugin)
func (*FileManager) CreateManagedFileFromFileHeader ¶ added in v0.4.0
func (fm *FileManager) CreateManagedFileFromFileHeader(fileHeader *multipart.FileHeader, targetStorageType FileStorageType) (*ManagedFile, error)
CreateManagedFileFromFileHeader creates a ManagedFile from a multipart.FileHeader which is typical in HTTP file uploads.
func (*FileManager) CreateManagedFileFromPath ¶ added in v0.4.0
func (fm *FileManager) CreateManagedFileFromPath(localPath string, targetStorageType FileStorageType) (*ManagedFile, error)
CreateManagedFileFromPath creates a ManagedFile from a given local path.
func (*FileManager) CreateManagedFileFromResponseBody ¶ added in v0.5.1
func (fm *FileManager) CreateManagedFileFromResponseBody(filename string, responseBody io.ReadCloser, targetStorageType FileStorageType) (*ManagedFile, error)
CreateManagedFileFromResponseBody creates a ManagedFile from a response body. will NOT CLOSE the response body.
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) (pubUrl string, err error)
func (*FileManager) GetRecipe ¶ added in v0.2.1
func (fm *FileManager) GetRecipe(name string) (Recipe, error)
func (*FileManager) HandleFileUpload ¶
func (fm *FileManager) HandleFileUpload(r io.Reader, fileProcess *FileProcess, statusCh chan<- *FileProcess) (*ManagedFile, error)
func (*FileManager) LoadRecipes ¶
func (fm *FileManager) LoadRecipes(recipesDir string) error
func (*FileManager) LogTo ¶ added in v0.5.0
func (fm *FileManager) LogTo(level string, message string)
func (*FileManager) ProcessFile ¶
func (fm *FileManager) ProcessFile(file *ManagedFile, recipeName string, fileProcess *FileProcess, statusCh chan<- *FileProcess)
func (*FileManager) RunProcessingStep ¶ added in v0.4.1
func (fm *FileManager) RunProcessingStep(file *ManagedFile, pluginName string, params map[string]any, targetStorageType FileStorageType) (*ManagedFile, error)
RunProcessingStep applies a single processing step to a ManagedFile.
type FileProcess ¶ added in v0.2.1
type FileProcess struct { ID string IncomingFileName string RecipeName string ProcessingUpdates []ProcessingStatus LatestStatus *ProcessingStatus }
func NewFileProcess ¶ added in v0.2.1
func NewFileProcess(incomingFileName, recipeName string) *FileProcess
func (*FileProcess) AddProcessingUpdate ¶ added in v0.2.1
func (fp *FileProcess) AddProcessingUpdate(update ProcessingStatus)
func (*FileProcess) GetLatestProcessingStatus ¶ added in v0.2.1
func (fp *FileProcess) GetLatestProcessingStatus() *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, fileProcess *FileProcess) ([]*ManagedFile, error)
type ImageManipulationPlugin ¶
type ImageManipulationPlugin struct{}
func (*ImageManipulationPlugin) Process ¶
func (p *ImageManipulationPlugin) Process(files []*ManagedFile, fileProcess *FileProcess) ([]*ManagedFile, error)
type LogAdapter ¶ added in v0.5.0
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"` TargetFileNames []string `yaml:"target_file_names"` StorageType FileStorageType `yaml:"storage_type"` // public, private, temp }
type PDFManipulationPlugin ¶
type PDFManipulationPlugin struct{}
func (*PDFManipulationPlugin) Process ¶
func (p *PDFManipulationPlugin) Process(files []*ManagedFile, fileProcess *FileProcess) ([]*ManagedFile, error)
type PDFTextExtractorPlugin ¶
type PDFTextExtractorPlugin struct{}
func (*PDFTextExtractorPlugin) Process ¶
func (p *PDFTextExtractorPlugin) Process(files []*ManagedFile, fileProcess *FileProcess) ([]*ManagedFile, error)
type ProcessingPlugin ¶
type ProcessingPlugin interface {
Process(files []*ManagedFile, fileProcess *FileProcess) ([]*ManagedFile, error)
}
type ProcessingResultFile ¶ added in v0.3.0
type ProcessingStatus ¶
type ProcessingStep ¶
type ProgressReader ¶
type ProgressReader struct { Reader io.Reader Size int64 Uploaded int64 StatusCh chan<- *FileProcess FileProcess *FileProcess Done bool }
type Recipe ¶
type Recipe struct { Name string `yaml:"name"` AcceptedMimeTypes []string `yaml:"accepted_mime_types"` MinFileSize int64 `yaml:"min_file_size"` MaxFileSize int64 `yaml:"max_file_size"` ProcessingSteps []ProcessingStep `yaml:"processing_steps"` OutputFormats []OutputFormat `yaml:"output_formats"` }
Source Files ¶
- filemanager.go
- filemanager.helpers.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.