file

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndConvertFile added in v1.0.5

func CheckAndConvertFile(file io.Reader, fileName string) (io.Reader, error)

CheckAndConvertFile checks if a file is an image and converts it to WebP Supports JPG, JPEG, and PNG formats; returns original file for unsupported types

func DeleteFile

func DeleteFile(filename, uploadDirectory string) error

DeleteFile removes a single file from the specified directory Takes the filename and directory path, deletes the file, and handles errors Returns an error if the file does not exist or deletion fails

func DeleteMultipleFiles added in v1.0.3

func DeleteMultipleFiles(filenames []string, uploadDirectory string) error

DeleteMultipleFiles removes multiple files from the specified directory Takes a slice of filenames and the directory path, attempts to delete each file Continues deletion even if some fail, returns an error with failed filenames

func UploadFile

func UploadFile(file io.Reader, fileName, uploadDirectory string, convertToWebP bool) (string, error)

UploadFile uploads a single file to the specified directory Optionally converts images to WebP, generates a unique kebab-case filename with a UUID, and copies the file content Returns the unique filename or an error if the upload fails

func UploadMultipleFiles added in v1.0.3

func UploadMultipleFiles(files []io.Reader, fileNames []string, uploadDirectory string, convertToWebP bool) ([]string, error)

UploadMultipleFiles handles the uploading of multiple files to the specified directory Optionally converts images to WebP, uploads each file, and ensures consistency Returns a slice of unique filenames or an error, rolling back on failure

Types

This section is empty.

Jump to

Keyboard shortcuts

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