utils

package
v0.0.0-...-1cc14b7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderBearerType = "Bearer"
	HeaderBasicType  = "Basic"
)
View Source
const (
	FoldersResourceType = 0
	FilesResourceType   = 1
)

Variables

This section is empty.

Functions

func CompareHashAndPasswordFromAuthHeader

func CompareHashAndPasswordFromAuthHeader(passwordHash []byte, r *http.Request) error

func ComparePasswordAndHash

func ComparePasswordAndHash(passwordHash []byte, encodedPassword string) error

func DecodeId

func DecodeId(hashId string, resourceType int) (int, error)

func DeleteFile

func DeleteFile(fileName string) error

func EncodeId

func EncodeId(id int, resourceType int) string

func GenerateRandomString

func GenerateRandomString(n int) string

func GetFileMD5Hash

func GetFileMD5Hash(file io.Reader) (string, error)

func GetFileNameWithTimestamp

func GetFileNameWithTimestamp(fileName string) string

func GetFileNameWithoutTimestamp

func GetFileNameWithoutTimestamp(fileName string) string

func GetFileSHA1Hash

func GetFileSHA1Hash(file io.Reader) (string, error)

func GetFileSizeInKilobytes

func GetFileSizeInKilobytes(file *os.File) (string, error)

func GetTokenFromAuthHeader

func GetTokenFromAuthHeader(authHeader string, headerType string) (string, error)

func Initialize

func Initialize(config *config.Config) error

func InitializeFiles

func InitializeFiles(config *config.Config) error

func InitializeHashId

func InitializeHashId(config *config.Config) error

func InitializeJWT

func InitializeJWT(config *config.Config)

func ReadFile

func ReadFile(fileName string) (*os.File, error)

func ReadFileByteStream

func ReadFileByteStream(fileName string) ([]byte, error)

func SaveMultipartFile

func SaveMultipartFile(file multipart.File, fileName string, w http.ResponseWriter, r *http.Request) error

func VerifyLoginJWT

func VerifyLoginJWT(authHeader string) (int, error)

Types

type Claims

type Claims struct {
	Email string `json:"email"`
	jwt.StandardClaims
}

type Files

type Files struct {
	// contains filtered or unexported fields
}

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

func CreateLoginJWT

func CreateLoginJWT(email string) (*TokenResponse, error)

type Utils

type Utils struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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