filetype

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package filetype contains methods and structs to deal with files (mime, validation, sha, etc.)

Index

Constants

This section is empty.

Variables

View Source
var ErrMsgUnsupportedImageFormat = "unsupported image format"

ErrMsgUnsupportedImageFormat represents the error message returned for an unsupported image type

Functions

func IsGIF

func IsGIF(r io.ReadSeeker) (bool, error)

IsGIF validates a GIF file

func IsImage

func IsImage(r io.ReadSeeker) (isValid bool, mimeType string, err error)

IsImage checks the specified reader contains an image

func IsJPG

func IsJPG(r io.ReadSeeker) (bool, error)

IsJPG validates a JPG file

func IsPNG

func IsPNG(r io.ReadSeeker) (bool, error)

IsPNG validates a PNG file

func MimeType

func MimeType(r io.ReadSeeker) (string, error)

MimeType returns the mimetype of a file

func SHA256Sum

func SHA256Sum(r io.ReadSeeker) (hash string, err error)

SHA256Sum returns the SHA256 sum of a reader

func ValidateImage

func ValidateImage(r io.ReadSeeker, decode ImageDecoder) (bool, error)

ValidateImage check if an images has a valid format Update when this gets done: https://github.com/golang/go/issues/18098

Types

type FileValidator

type FileValidator func(r io.ReadSeeker) (bool, error)

FileValidator represents a function that can validate a file type

type ImageDecoder

type ImageDecoder func(r io.Reader) (image.Image, error)

ImageDecoder is a type that represents an image decoder

Jump to

Keyboard shortcuts

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