From 2c095d1fcab123bd20092310c1fce95a45bf3008 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Mon, 18 Aug 2025 21:46:27 +0800 Subject: [PATCH] fix: remove token --- internal/version/VERSION | 2 +- uixt/driver_utils.go | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/version/VERSION b/internal/version/VERSION index a1341323..fe0cb932 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-250815 +v5.0.0-250818 diff --git a/uixt/driver_utils.go b/uixt/driver_utils.go index f583c84d..d48f54bf 100644 --- a/uixt/driver_utils.go +++ b/uixt/driver_utils.go @@ -386,8 +386,18 @@ func DownloadFileByUrl(fileUrl string) (filePath string, err error) { return filePath, nil } +var ( + VEDEM_UPLOAD_URL = os.Getenv("VEDEM_UPLOAD_URL") + VEDEM_UPLOAD_ACCESS_KEY = os.Getenv("VEDEM_UPLOAD_ACCESS_KEY") + VEDEM_UPLOAD_TOKEN = os.Getenv("VEDEM_UPLOAD_TOKEN") +) + // uploadScreenshot uploads a screenshot to the server and returns the URL func uploadScreenshot(imagePath string, imageBuffer *bytes.Buffer) (string, error) { + if VEDEM_UPLOAD_URL == "" || VEDEM_UPLOAD_ACCESS_KEY == "" || VEDEM_UPLOAD_TOKEN == "" { + return "", errors.Wrap(code.ConfigureError, "upload service env not configured") + } + // Create a new buffer for the multipart form var requestBody bytes.Buffer writer := multipart.NewWriter(&requestBody) @@ -409,16 +419,15 @@ func uploadScreenshot(imagePath string, imageBuffer *bytes.Buffer) (string, erro } // Create the HTTP request - uploadURL := "https://gtf-eapi-cn.bytedance.com/cn/upload/xxx" - req, err := http.NewRequest("POST", uploadURL, &requestBody) + req, err := http.NewRequest("POST", VEDEM_UPLOAD_URL, &requestBody) if err != nil { return "", errors.Wrap(code.UploadFailed, err.Error()) } // Set headers req.Header.Set("Content-Type", writer.FormDataContentType()) - req.Header.Set("accessKey", "ies.vedem.video") - req.Header.Set("token", "***REMOVED***") + req.Header.Set("accessKey", VEDEM_UPLOAD_ACCESS_KEY) + req.Header.Set("token", VEDEM_UPLOAD_TOKEN) // Create HTTP client with HTTP/1.1 support client := &http.Client{ @@ -428,7 +437,7 @@ func uploadScreenshot(imagePath string, imageBuffer *bytes.Buffer) (string, erro } // Send the request - log.Debug().Str("url", uploadURL).Str("imagePath", imagePath).Msg("uploading screenshot") + log.Debug().Str("url", VEDEM_UPLOAD_URL).Str("imagePath", imagePath).Msg("uploading screenshot") resp, err := client.Do(req) if err != nil { return "", errors.Wrap(code.UploadFailed, err.Error())