fix(web): accept 2xx status codes in upload function for HTTP semantics

The upload helper was hardcoded to only accept HTTP 201, which broke
PUT requests that return 200. This aligns with standard HTTP semantics
where POST returns 201 Created and PUT returns 200 OK.
This commit is contained in:
yyh
2026-01-15 10:54:42 +08:00
parent 18c7f4698a
commit f8b27dd662

View File

@ -396,7 +396,9 @@ export const upload = async (options: UploadOptions, isPublicAPI?: boolean, url?
xhr.responseType = 'json'
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 201)
// Accept any 2xx status code per HTTP semantics
// POST returns 201 Created, PUT returns 200 OK
if (xhr.status >= 200 && xhr.status < 300)
resolve(xhr.response)
else
reject(xhr)