Files
2025-11-17 17:18:22 +07:00

34 lines
735 B
Go

package filehelper
import (
"fmt"
"os"
"path/filepath"
)
// const DEFAULT_EXPIRY_FILES = time.Hour * 24 * 7
func PathAgreement(medicalNumber string) (string, error) {
outputPath := fmt.Sprintf("./public/patient/%s", medicalNumber)
err := os.MkdirAll(outputPath, os.ModePerm)
return outputPath, err
}
func PathToSaveFile(outputPath string) (string, error) {
err := os.MkdirAll(outputPath, os.ModePerm)
return outputPath, err
}
func RenameFile(srcPath, dstPath string) error {
return os.Rename(srcPath, dstPath)
}
func DeleteFolder(path string) error {
return os.RemoveAll(path)
}
func PathToUrl(fileName string) *string {
fileUrl := filepath.ToSlash(fmt.Sprintf("%c%s", os.PathSeparator, fileName))
return &fileUrl
}