fix(brand): 品牌检测源文件改走 OSS URL(服务端化跨节点组装可用)
前端上传桥与降级桥透传 uploadOss;品牌页提交时 fileUrl 优先取上传响应的 OSS url,localPath 仅作旧桌面桥兜底。
This commit is contained in:
@@ -286,7 +286,7 @@ async function uploadBrandPathsToJava(paths: Array<string | BrandExpandFolderIte
|
||||
for (const item of paths) {
|
||||
const filePath = typeof item === 'string' ? item : item.absolutePath
|
||||
const relativePath = typeof item === 'string' ? undefined : item.relativePath
|
||||
const uploaded = await api.upload_file_to_java(filePath, relativePath)
|
||||
const uploaded = await api.upload_file_to_java(filePath, relativePath, true)
|
||||
if (!uploaded?.success || !uploaded.data) {
|
||||
throw new Error(uploaded?.error || uploaded?.message || `上传失败:${filePath}`)
|
||||
}
|
||||
@@ -356,12 +356,13 @@ async function submitRun() {
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
// 上传后以服务器可读的 localPath 作为 fileUrl(Java resolveSourceFile 直接读临时文件)
|
||||
// 上传后以可跨节点下载的源地址作为 fileUrl:优先 OSS url(uploadToOss=true 的桌面桥),
|
||||
// 旧桌面桥只回 localPath(Java 容器临时路径,双活组装可能读不到),作为兜底仍透传。
|
||||
const files: UploadedFileRef[] = uploadedFiles.value.map((f) => ({
|
||||
fileKey: f.fileKey,
|
||||
originalFilename: f.originalFilename,
|
||||
relativePath: f.relativePath,
|
||||
fileUrl: f.localPath,
|
||||
fileUrl: f.url || f.localPath,
|
||||
}))
|
||||
if (runMode.value === 'immediate') {
|
||||
const res = await runBrandNow(files, strategy.value)
|
||||
|
||||
@@ -93,6 +93,7 @@ export interface PywebviewApi {
|
||||
upload_file_to_java?: (
|
||||
filePath: string,
|
||||
relativePath?: string,
|
||||
uploadOss?: boolean,
|
||||
) => Promise<{
|
||||
success: boolean;
|
||||
message?: string;
|
||||
|
||||
@@ -125,8 +125,8 @@ export const webFallbackApi: PywebviewApi = {
|
||||
return registerWebFiles(files)
|
||||
},
|
||||
|
||||
/** 虚拟路径 → 浏览器 File → 上传 Java 临时目录;返回结构与桌面桥一致(透传 Java ApiResponse<UploadFileVo>) */
|
||||
async upload_file_to_java(filePath, relativePath) {
|
||||
/** 虚拟路径 → 浏览器 File → 上传 Java;uploadOss=true 时同时上传公开 OSS(品牌检测等服务端化工具用) */
|
||||
async upload_file_to_java(filePath, relativePath, uploadOss) {
|
||||
const file = typeof filePath === 'string' ? webFileMap.get(filePath) : undefined
|
||||
if (!file) {
|
||||
return { success: false, error: '文件不存在,请重新选择' }
|
||||
@@ -136,6 +136,10 @@ export const webFallbackApi: PywebviewApi = {
|
||||
if (relativePath) {
|
||||
form.append('relativePath', relativePath)
|
||||
}
|
||||
if (uploadOss) {
|
||||
form.append('uploadToOss', 'true')
|
||||
form.append('moduleType', 'BRAND')
|
||||
}
|
||||
try {
|
||||
// http 实例对 /newApi 前缀自动附带 Bearer;FormData 的 Content-Type 交由浏览器自动生成(含 boundary)
|
||||
const response = await http.post('/newApi/api/files/upload', form, { timeout: 120000 })
|
||||
|
||||
Reference in New Issue
Block a user