mirror of
https://github.com/Dadido3/Scanyonero.git
synced 2025-06-06 01:10:00 +00:00
- 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.
38 lines
673 B
Go
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
|
|
}
|