Merge origin/release/test and preserve storage rent checks with request unlock

This commit is contained in:
2026-10-26 13:51:38 +08:00
52 changed files with 761 additions and 761 deletions
-1
View File
@@ -21,6 +21,5 @@ export function normalizeLoadingDocuments(value, no) {
}
export async function getLoadingDocuments(no) { return normalizeLoadingDocuments(await overseasRequest('GET', path(no)), no) }
export function uploadLoadingPhoto(no, slot, filePath, key) { return overseasUpload(`${slotPath(no, slot)}/uploads?idempotencyKey=${encodeURIComponent(key)}`, filePath) }
export function recoverLoadingPhoto(no, key) { return overseasRequest('GET', `${path(no)}/uploads/${encodeURIComponent(key)}`) }
export async function bindLoadingPhoto(no, slot, body) { return normalizeLoadingDocuments(await overseasRequest('PUT', slotPath(no, slot), body), no) }
export function readLoadingPhoto(no, photo) { return overseasDownload(`${slotPath(no, photo.slot)}/files/${encodeURIComponent(photo.fileId)}/content`, { expectedContentTypePrefix: 'image/' }) }
+12 -2
View File
@@ -135,12 +135,22 @@ function rawUpload(path, filePath, name, token) {
const request = new XMLHttpRequest()
request.open('POST', url)
request.setRequestHeader('Authorization', `Bearer ${token}`)
request.timeout = 60000
request.onload = () => resolve({ statusCode: request.status, data: request.responseText, header: {} })
request.onerror = () => reject(new Error('海外作业文件上传失败'))
request.ontimeout = () => reject(new Error('照片上传超时,请重试'))
request.onabort = () => reject(new Error('照片上传已中断,请重试'))
request.send(form)
})
const response = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: form })
return { statusCode: response.status, data: await response.text(), header: Object.fromEntries(response.headers.entries()) }
const controller = new AbortController()
const timeout = setTimeout(() => controller.abort(), 60000)
try {
const response = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: form, signal: controller.signal })
return { statusCode: response.status, data: await response.text(), header: Object.fromEntries(response.headers.entries()) }
} catch (cause) {
if (controller.signal.aborted) throw new Error('照片上传超时,请重试')
throw cause
} finally { clearTimeout(timeout) }
})
.catch((cause) => { throw Object.assign(new Error(cause.message || '海外作业文件上传失败'), { network: true, uploadUrl: url }) })
}