Documentation
¶
Index ¶
- Constants
- func AddFileToTarWriter(pathOnDisk string, pathInTar string, tarWriter *tar.Writer) error
- func AddSuffixToBasename(fullpath string, suffix string) string
- func ChangeSuffix(filename string, newSuffix string) string
- func ConvertHeicJpg(inputPath string) error
- func ConvertM4aMp4(inputPath string) error
- func CopyDir(source, destination string) error
- func CopyFile(src, dst string) (int64, error)
- func CreateAltSizes(mediaPath string, altName string) (imagePathsThumbs []string, altNameThumbs []string, err error)
- func CreateThumbnailsInFolder(mediaPath string) error
- func DeleteFile(path string) error
- func ExpandTarFile(tarFilePath string, expandDirPath string) error
- func ExpandTarReader(r io.Reader, expandDirPath string) error
- func GenerateBase64Rand() string
- func GenerateCid() (string, error)
- func GenerateRandomNumber() int
- func GeoBoundingBox(lat float64, lon float64, d float64) (lat1 float64, lon1 float64, lat2 float64, lon2 float64)
- func GeoDistance(lat1 float64, lon1 float64, lat2 float64, lon2 float64) float64
- func GetFileContentType(out *os.File) (string, error)
- func GetMediaFormatAndMetadata(path string, suffix string) (mediaFormat int, mediaFormatDetail int, metadata map[string]string, err error)
- func GetMediaSuffix(path string) (suffix string)
- func GetThumbnailName(imageName string, format string) string
- func InitMediaStorage()
- type IPFS_Driver
- func (i *IPFS_Driver) DownloadDirectory(localDirPath string, cid string) error
- func (i *IPFS_Driver) Init() error
- func (i *IPFS_Driver) UploadDirectory(localDirPath string) (cid string, err error)
- func (i *IPFS_Driver) UploadFile(localPath string, relPath string) (cid string, err error)
- func (i *IPFS_Driver) UploadString(body string, relPath string) (cid string, err error)
- type S3_1Driver
- func (s *S3_1Driver) CreateFolderNameBase64(text string) string
- func (s *S3_1Driver) Download(localPath string, key string) error
- func (s *S3_1Driver) DownloadDirectory(localDirPath string, cid string) error
- func (s *S3_1Driver) GetExpiringURL(key string) (string, http.Header, error)
- func (s *S3_1Driver) Init() error
- func (s *S3_1Driver) Upload(localPath string, key string) error
- func (s *S3_1Driver) UploadDirectory(localDirPath string, cid string) error
- func (s *S3_1Driver) UploadString(body string, contentType string, folder string, key string) error
- type ThumbnailSizeSuffix
Constants ¶
const ( MediaFormatBase = 1000 // base used for comparisons MediaFormatImage = 1000 // image base code MediaFormatDetailImageJpeg = 1001 // jpeg MediaFormatDetailImagePng = 1002 // png MediaFormatDetailImageHeic = 1003 // heic MediaFormatAudio = 2000 // audio base code MediaFormatDetailAudioMp3 = 2001 // mp3 MediaFormatDetailAudioMp4 = 2002 // audio only mp4 MediaFormatDetailAudioAac = 2003 // audio only aac MediaFormatDetailAudioOgg = 2004 // audio only ogg MediaFormatVideo = 3000 // video base code MediaFormatDetailVideoMp4 = 3001 // mp4 MediaFormatDetailVideoMov = 3002 // mov Thumb_p100 = "p100" Thumb_p1080 = "p1080" Size_Actual = "actual" )
const ThumbnailSuffixDelim = "_"
Variables ¶
This section is empty.
Functions ¶
func AddFileToTarWriter ¶
AddFileToTarWriter adds a file to a tar file
func AddSuffixToBasename ¶
AddSuffixToBasename adds suffix to base of filename, for example filename.jpg to filename_t1.jpg
func ChangeSuffix ¶
ChangeSuffix changes the suffix of filename from .from to .to
func ConvertHeicJpg ¶
ConvertHeicJpg converts an heic file to jpeg in place by using temp folder to create new file then copies to original convert -format jpg input.heic output.jpg
func ConvertM4aMp4 ¶
ConvertM4aMp4 converts an m4a file to mp4 in place by using temp folder to create new file then copies to original ffmpeg -y -i input.m4a -c:a copy output.mp4
func CreateAltSizes ¶
func CreateAltSizes(mediaPath string, altName string) (imagePathsThumbs []string, altNameThumbs []string, err error)
CreateAltSizes creates thumbnails of mediaPath, saves thumbnails, and returns paths and names of uploaded images. Thumbnail size is set to max of width or height. mediaPath is the path to the file, altName is an alternate name that gets thumbnail suffixes added to it
func CreateThumbnailsInFolder ¶
CreateThumbnailsInFolder creates thumbnails for all images in the folder. The thumbnails appear next to the images with _p1080 basename suffix, like this a.jpg => a_p1080.jpg
func ExpandTarFile ¶
ExpandTarFile expands a tar file tarFilePath to expandDirPath
func ExpandTarReader ¶
ExpandTarReader expands a tar stream to expandDirPath
func GenerateBase64Rand ¶
func GenerateBase64Rand() string
GenerateBase64Rand generates a base64 random string
func GenerateRandomNumber ¶
func GenerateRandomNumber() int
GenerateRandomNumber generates a random number
func GeoBoundingBox ¶
func GeoBoundingBox(lat float64, lon float64, d float64) (lat1 float64, lon1 float64, lat2 float64, lon2 float64)
GeoBoundingBox returns bounding box given center point and range d in kilometers This is an estimate since uses the hypotenuse at NW and SE
func GeoDistance ¶
GeoDistance returns the greater circle distance in kilometers between two points
func GetFileContentType ¶
GetFileContentType detects the content type of a file
func GetMediaFormatAndMetadata ¶
func GetMediaFormatAndMetadata(path string, suffix string) (mediaFormat int, mediaFormatDetail int, metadata map[string]string, err error)
GetMediaFormatAndMetadata returns media format (image, audio, video), detail (jpeg, png, etc.) and metadata map for a media file
func GetMediaSuffix ¶
GetMediaSuffix returns the suffix of a file name
func GetThumbnailName ¶
GetThumbnailName returns thumbnail name given image name and format. Format could be p100, p1080, etc.
Types ¶
type IPFS_Driver ¶
type IPFS_Driver struct {
// contains filtered or unexported fields
}
IPFS_Driver struct manages IPFS
var Ipfs IPFS_Driver
func (*IPFS_Driver) DownloadDirectory ¶
func (i *IPFS_Driver) DownloadDirectory(localDirPath string, cid string) error
DownloadDirectory downloads all the files in a folder identified by CID
func (*IPFS_Driver) UploadDirectory ¶
func (i *IPFS_Driver) UploadDirectory(localDirPath string) (cid string, err error)
UploadDirectory uploads all the files in a folder. Files are stored in IPFS in directory prefixPath.
func (*IPFS_Driver) UploadFile ¶
func (i *IPFS_Driver) UploadFile(localPath string, relPath string) (cid string, err error)
UploadFile loads a file to IPFS with relPath relative path. Files are stored in IPFS in directory prefixPath.
func (*IPFS_Driver) UploadString ¶
func (i *IPFS_Driver) UploadString(body string, relPath string) (cid string, err error)
Upload loads a string with relPath relative path. Files are stored in IPFS in directory prefixPath.
type S3_1Driver ¶
type S3_1Driver struct {
// contains filtered or unexported fields
}
S3_1Driver struct manages S3 uploads and URL generation
var S3 S3_1Driver
func (*S3_1Driver) CreateFolderNameBase64 ¶
func (s *S3_1Driver) CreateFolderNameBase64(text string) string
CreateFolderNameBase64 creates folder name from a string. Creates an base64 HMAC given the string. Sanitizes by removing all non-alphanumerics
func (*S3_1Driver) Download ¶
func (s *S3_1Driver) Download(localPath string, key string) error
Download loads a file FROM S3
func (*S3_1Driver) DownloadDirectory ¶
func (s *S3_1Driver) DownloadDirectory(localDirPath string, cid string) error
DownloadDirectory downloads all the files in a folder
func (*S3_1Driver) GetExpiringURL ¶
GetExpiringURL gets a URL to s3 asset that expires, given folder and filename for config set bucket name
func (*S3_1Driver) Upload ¶
func (s *S3_1Driver) Upload(localPath string, key string) error
Upload loads a file TO S3
func (*S3_1Driver) UploadDirectory ¶
func (s *S3_1Driver) UploadDirectory(localDirPath string, cid string) error
UploadDirectory uploads all the files in a folder
func (*S3_1Driver) UploadString ¶
Upload loads a string TO S3, must specify mimeType (contentType)