opt: change the relative path with absolute path for midjourney image uploading

This commit is contained in:
RockYang
2024-03-31 17:45:22 +08:00
parent b35d95f0c7
commit 4596c1049c
2 changed files with 13 additions and 0 deletions

View File

@@ -145,6 +145,13 @@ func (h *MidJourneyHandler) Image(c *gin.Context) {
prompt = fmt.Sprintf("%s:%s", data.TaskType, strings.Join(data.ImgArr, ","))
}
// 如果本地图片上传的是相对地址,处理成绝对地址
for k, v := range data.ImgArr {
if !strings.HasPrefix(v, "http") {
data.ImgArr[k] = fmt.Sprintf("http://localhost:5678/%s", strings.TrimLeft(v, "/"))
}
}
idValue, _ := c.Get(types.LoginUserID)
userId := utils.IntValue(utils.InterfaceToString(idValue), 0)
// generate task id