feat(libreoffice): preserve filenames for zipped files instead of using randomly generated UUID filenames (#793)

* feat(libreoffice): preserve filenames for zipped files instead of using generated UUID filenames

* chore: move github.com/google/uuid back to its original line

* fix: add libreoffice/routes.go to PR
This commit is contained in:
Chris Hughes
2024-02-16 07:29:22 -08:00
committed by Julien Neuhart
parent e6d7131701
commit 089f161d1e
3 changed files with 101 additions and 5 deletions

View File

@@ -191,10 +191,18 @@ func (ctx *Context) FormData() *FormData {
}
}
// GeneratePath generates a path within the context's working directory. It
// does not create a file.
func (ctx *Context) GeneratePath(extension string) string {
return fmt.Sprintf("%s/%s%s", ctx.dirPath, uuid.New(), extension)
// GeneratePath generates a path within the context's working directory. It does not create a file.
// It either generates a new UUID-based filename or uses the provided filename.
func (ctx *Context) GeneratePath(extension string, optionalFilename ...string) string {
var filename string
if len(optionalFilename) > 0 {
// Use the provided filename
filename = optionalFilename[0]
} else {
// Generate a new UUID-based filename
filename = uuid.New().String()
}
return fmt.Sprintf("%s/%s%s", ctx.dirPath, filename, extension)
}
// AddOutputPaths adds the given paths. Those paths will be used later to build