file

package
v0.0.0-...-d9ef67d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Payload

type Payload struct {
	multipart.File
	Size      int64
	Filename  string
	MimeType  string
	Extension string
}

func NewPayload

func NewPayload(file multipart.File, fh *multipart.FileHeader, mimetype string) (*Payload, error)

type Service

type Service struct {
	Directory string
	Archive   string
}

func NewService

func NewService(path string) (*Service, error)

func (*Service) ArchiveBook

func (s *Service) ArchiveBook(book *dusk.Book) error

func (*Service) DeleteBook

func (s *Service) DeleteBook(book *dusk.Book) error

The full flow of deleting/archiving a book is: 1. Delete book from database 2. Delete book directory from filesystem 3. If step 1 fails, worker should identify orphan directories and flag them

func (*Service) ParseBook

func (s *Service) ParseBook(payload *Payload) (*dusk.Book, error)

Book format and cover files should not be uploaded to the filesystem directly if they have not been initialized in the database, in case of database errors. This removes the need to perform clean up if any database errors should occur.

As such, the full flow of adding a new book via upload is:

  1. Parse book from payload
  2. Add book entry to database
  3. Upload book files
  4. Update database with book file paths

func (*Service) UploadBookFormat

func (s *Service) UploadBookFormat(payload *Payload, book *dusk.Book) error

Upload new format for existing book

func (*Service) UploadCoverFromPayload

func (s *Service) UploadCoverFromPayload(payload *Payload, book *dusk.Book) error

Upload book cover from payload

func (*Service) UploadCoverFromUrl

func (s *Service) UploadCoverFromUrl(url string, book *dusk.Book) error

Upload book cover from URL for existing book

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL