[1.3] 신고

- 데모 파일 압축해서 업로드하도록 수정
This commit is contained in:
2025-07-11 18:56:31 +09:00
parent 19a4ff103f
commit 63727343ee

View File

@ -1,12 +1,14 @@
package client
import (
"archive/zip"
"bytes"
"crypto/aes"
"crypto/md5"
"encoding/base64"
"encoding/hex"
"errors"
"io"
"os"
"path/filepath"
"strings"
@ -126,11 +128,58 @@ func validatePipeReq(command, param, receivedHash string) error {
}
func handleStdOutUploadRequest(hc *houstonClient, meta *procmeta, param string) error {
uploadFullPath := param
if _, err := os.Stat(uploadFullPath); err != nil {
if uploadZipPath, err := compressFile(param); err != nil {
return err
} else {
hc.uploadToAppendFile(uploadFullPath, meta.name, meta.version, filepath.Base(uploadFullPath))
hc.uploadToAppendFile(uploadZipPath, meta.name, meta.version, filepath.Base(uploadZipPath))
}
return nil
}
func compressFile(fullPath string) (string, error) {
ext := filepath.Ext(fullPath)
zipFullPath := fullPath[:len(fullPath)-len(ext)] + ".zip"
// Create
newZipFile, err := os.Create(zipFullPath)
if err != nil {
return "", err
}
defer newZipFile.Close()
zipWriter := zip.NewWriter(newZipFile)
defer zipWriter.Close()
// Open
fileToZip, err := os.Open(fullPath)
if err != nil {
return "", err
}
defer fileToZip.Close()
fileToZipInfo, err := fileToZip.Stat()
if err != nil {
return "", err
}
// Zip
fileToZipHeader, err := zip.FileInfoHeader(fileToZipInfo)
if err != nil {
return "", err
}
fileToZipHeader.Name = fileToZipInfo.Name()
fileToZipHeader.Method = zip.Deflate
fileToZipWriter, err := zipWriter.CreateHeader(fileToZipHeader)
if err != nil {
return "", err
}
_, err = io.Copy(fileToZipWriter, fileToZip)
if err != nil {
return "", err
}
// Remove
err = os.Remove(fullPath)
if err != nil {
return "", err
}
return zipFullPath, nil
}