Scanyonero/document/file.go
David Vogel 853a1bb58d Rework into FTP scanning server
- Rename to Scanyonero
- Add FTP server that ingests TIFF, PNG, JPEG or PDF files
- Add web interface to check and modify ingested files
- Rework how ocrmypdf is invoked

Basics are working, but the program is not in a usable state.
2025-05-14 12:08:38 +02:00

38 lines
673 B
Go

package document
import (
"fmt"
"log"
"os"
)
// File contains the raw data of a file coming from a scanner.
type File struct {
Name string
Data []byte
}
// LoadFile reads a file and returns it as a File.
func LoadFile(filename string) (File, error) {
data, err := os.ReadFile(filename)
if err != nil {
return File{}, fmt.Errorf("couldn't read file: %w", err)
}
return File{
Name: filename,
Data: data,
}, nil
}
// LoadFile reads a file and returns it as a File.
// This will panic on any error.
func MustLoadFile(filename string) File {
file, err := LoadFile(filename)
if err != nil {
log.Panicf("Failed to load file: %v.", err)
}
return file
}