utils

package
v0.0.0-...-f8fee01 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateR2Client

func CreateR2Client(accessKeyID string, accessKeySecret string, accountID string) *r2.Client

CreateR2Client creates a new R2 client

func ErrorHandler

func ErrorHandler(err error)

ErrorHandler is a generic error handler

func GenerateUUID

func GenerateUUID() string

GenerateUUID generates a UUID

func GetLocationNameFromURL

func GetLocationNameFromURL(url string, scrapOption string) string

GetLocationNameFromURL get the scrape target name from the given URL

func ParseTime

func ParseTime(timeToParse string) string

ParseTime converts ISO 8601 time to a more readable format

func R2UploadObject

func R2UploadObject(fileName string, uploadIdentifier string, fileData io.Reader)

R2UploadObject upload an object to R2

func ReadFromFile

func ReadFromFile(fileName string) *os.File

ReadFromFile reads a file from disk

func ValidateEmailAddress

func ValidateEmailAddress(email string) bool

ValidateEmailAddress validates the EHL email address

func ValidateTripAdvisorURL

func ValidateTripAdvisorURL(url string, scrapOption string) bool

ValidateTripAdvisorURL validates the TripAdvisor URLs

func WriteToFileFromTarStream

func WriteToFileFromTarStream(fileName string, fileSuffix string, tarF io.ReadCloser) string

WriteToFileFromTarStream writes a file to disk

Types

type Creds

type Creds struct {
	AccessKeyID     string `json:"accessKeyId"`
	AccessKeySecret string `json:"accessKeySecret"`
	AccountID       string `json:"accountId"`
	BucketName      string `json:"bucketName"`
}

Creds is the Credentials of the R2 bucket

func ParseCredsFromJSON

func ParseCredsFromJSON(fileName string) Creds

ParseCredsFromJSON parses the credentials from a JSON file

type R2Obj

type R2Obj struct {
	ChecksumAlgorithm string `json:"checksumAlgorithm"`
	Etag              string `json:"Etag"`
	Key               string `json:"Key"`
	LastModified      string `json:"LastModified"`
	Size              int64  `json:"Size"`
	StorageClass      string `json:"StorageClass"`
	Metadata          string
}

R2Obj is an object struct for R2 bucket objects

func R2EnrichMetaData

func R2EnrichMetaData(r2ObjectList []R2Obj) []R2Obj

R2EnrichMetaData enriches the R2 object in the list with the metadata

func R2ListObjects

func R2ListObjects() []R2Obj

R2ListObjects List objects in R2 and return a string slice of the file names

Jump to

Keyboard shortcuts

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