funbook

package
v0.0.0-...-9478cb8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: GPL-3.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

View Source
const (

	// The character encoding for the email.
	CharSet = "UTF-8"
)

Variables

This section is empty.

Functions

func AddFileToS3

func AddFileToS3(s *session.Session, bucket string, filePath string, destPath string) error

AddFileToS3 will upload a single file to S3, it will require a pre-built aws session and will set file info like content type and encryption on the uploaded file. NOTE: This was the original boilerplate I copied from https://golangcode.com/uploading-a-file-to-s3/ It is _not_ currently used in the package because it was adapted into WriteBufferToS3() for our purposes.

func AddPickToS3

func AddPickToS3(s *session.Session, pickBytes []byte, pickPath string)

This is a placeholder to write the byte array of the picked paragraph to a text file in S3, but it will be replaced by something to write the paragraph into an email instead.

func GetPickLocal

func GetPickLocal() (int, string, string)

Picks a random paragraph from fbutils.OutDir and returns the number of the pick (int), the the text retrieved from the picked file (string), and the file path that the text came from (string). Note that it will panic on an unexpected error through PanicNonPathError(). We may want to refactor this to return errors later, but given the missingErr pattern it was easier to do this.

func GetPickS3

func GetPickS3(s *session.Session) (int, []byte, string)

Picks a random paragraph from S3 and returns the number of the pick (int), the byte slice of the text retrieved from S3 ([]byte), and the S3 path that the slice came from (string). Note that it will panic on an unexpected error through PanicNonS3Missing(). We may want to refactor this to return errors later, but given the missingErr pattern it was easier to do this.

func GetValidSesAddresses

func GetValidSesAddresses(s *session.Session) []string

func ParseHtml

func ParseHtml(s string) (bool, string)

func ReadFileFromS3

func ReadFileFromS3(s *session.Session, bucket string, key string) ([]byte, error)

Reads a file from S3 into a buffer. This function requires a pre-built aws session.

func ReadPickLocal

func ReadPickLocal(path string, n int) (string, string, error)

Read a file from directory passed to path and filename of n zero-padded to 5 digits.

func SendSESEmail

func SendSESEmail(
	s *session.Session,
	Sender string,
	Recipients []string,
	Subject string,
	TextBody string,
)

func WriteBufferToS3

func WriteBufferToS3(s *session.Session, bucket string, buffer []byte, destPath string) error

WriteBufferToS3 uploads a buffer (byte slice) to a file in S3. The `destPath` argument is often called a `key` in S3 terminology. Destination file will be at s3://[bucket]/[destPath] This function requires a pre-built aws session and will set file info like content type and encryption on the uploaded file.

func WritePickLocal

func WritePickLocal(s string, n int, outDir string)

Write string to file in outDir with filename of n zero-padded to 5 digits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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