feat(template): add Templating functionality and endpoint
This commit is contained in:
22
pkg/svg/actions/download.go
Normal file
22
pkg/svg/actions/download.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
|
||||
"tomatentum.net/svg-templater/pkg/format"
|
||||
"tomatentum.net/svg-templater/pkg/svg"
|
||||
)
|
||||
|
||||
func ProvideFile(r *TemplateParameters, conversion *format.ConversionParameters) (string, error) {
|
||||
templatedSvgblob, err := Template(r)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
log.Printf("Converting %s to format %s (w=%d,h=%d)", r.Id, conversion.Format, conversion.Width, conversion.Height)
|
||||
result, err := format.ConvertByte(templatedSvgblob, *conversion)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return svg.Storage.CreatePublic(bytes.NewReader(result), conversion.Format)
|
||||
}
|
||||
Reference in New Issue
Block a user