[ Cmii ] [ Octopus ] - add Image Function - 1

This commit is contained in:
zeaslity
2024-03-26 14:07:51 +08:00
parent 2af05c903c
commit 20ba7a9f38
8 changed files with 376 additions and 79 deletions

View File

@@ -522,6 +522,46 @@ func BasicDownloadFile(downloadUrl, desFile string) (downloadOk bool, resultLog
return true, nil
}
func BasicDownloadFileWithProxy(downloadUrl, proxyUrl, desFile string) (downloadOk bool, resultLog []string) {
var ok bool
if !BasicCommandExistByPath("curl") {
return false, []string{
"curl not exits!",
}
}
ok, resultLog = AllCommandExecutor([]string{
"curl",
"-x",
proxyUrl,
"-o",
desFile,
"--insecure",
"--max-time",
"5",
downloadUrl,
})
errLog := fmt.Sprintf("[BasicDownloadFileWithProxy] - download file [ %s ] with proxy [ %s ] from [ %s ] failed !", desFile, proxyUrl, downloadUrl)
if !ok {
log.Error(errLog)
return false, []string{
errLog,
}
}
// check file exists
existAndNotNull := BasicFileExistAndNotNull(desFile)
if !existAndNotNull {
return false, []string{
errLog,
"[BasicDownloadFile] - file not exist !",
}
}
return true, nil
}
// BasicAppendSourceToFile 将源文件的内容添加到目标文件使用golang标准库完成跨平台、安全性更强
func BasicAppendSourceToFile(sourceFile, targetFile string) bool {