feat(backend): add CopyFile function for file duplication utility

This commit is contained in:
keven1024
2025-06-02 12:46:13 +08:00
parent 8cd9f278ba
commit 4bcab3ba5b

View File

@@ -45,3 +45,20 @@ func GetUploadDirPath() (string, error) {
}
return uploadPath, nil
}
func CopyFile(src, dst string) error {
sourceFile, err := os.Open(src)
if err != nil {
return err
}
defer sourceFile.Close()
destFile, err := os.Create(dst)
if err != nil {
return err
}
defer destFile.Close()
_, err = io.Copy(destFile, sourceFile)
return err
}