fix: extension upload uses server-signed content type + better error logging
The presigned URL is signed with a specific Content-Type (determined by the server's MIME map). If the browser's file.type doesn't match (common for broadcast formats like MXF, R3D, BRAW), S3 rejects the PUT with a signature mismatch. Now the extension uses presigned.contentType from the server response instead of item.file.type. Also added console logging for upload requests and detailed error messages from S3 responses on failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8bb9cf7ce9
commit
3b39803b49
1 changed files with 13 additions and 3 deletions
|
|
@ -267,11 +267,15 @@ async function uploadHTTP(item, idx, prefix) {
|
||||||
contentType: item.file.type || 'application/octet-stream'
|
contentType: item.file.type || 'application/octet-stream'
|
||||||
});
|
});
|
||||||
if (!presigned.success) throw new Error(presigned.error);
|
if (!presigned.success) throw new Error(presigned.error);
|
||||||
|
// Use the content type from the server response (matches what was signed)
|
||||||
|
// NOT item.file.type which may differ from what the server determined
|
||||||
|
const signedContentType = presigned.contentType || item.file.type || 'application/octet-stream';
|
||||||
|
console.log(`[DW] Upload ${item.name} → ${presigned.url.substring(0, 60)}... (${signedContentType})`);
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('PUT', presigned.url);
|
xhr.open('PUT', presigned.url);
|
||||||
xhr.setRequestHeader('Content-Type', item.file.type || 'application/octet-stream');
|
xhr.setRequestHeader('Content-Type', signedContentType);
|
||||||
xhr.upload.onprogress = (e) => {
|
xhr.upload.onprogress = (e) => {
|
||||||
if (e.lengthComputable) {
|
if (e.lengthComputable) {
|
||||||
const pct = Math.round((e.loaded / e.total) * 100);
|
const pct = Math.round((e.loaded / e.total) * 100);
|
||||||
|
|
@ -279,8 +283,14 @@ async function uploadHTTP(item, idx, prefix) {
|
||||||
setFileStatus(idx, 'uploading', `${pct}%`);
|
setFileStatus(idx, 'uploading', `${pct}%`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onload = () => xhr.status < 300 ? resolve() : reject(new Error(`S3 ${xhr.status}`));
|
xhr.onload = () => {
|
||||||
xhr.onerror = () => reject(new Error('Network error'));
|
console.log(`[DW] S3 PUT ${item.name} → ${xhr.status}`);
|
||||||
|
xhr.status < 300 ? resolve() : reject(new Error(`S3 error ${xhr.status}: ${xhr.responseText?.substring(0, 200)}`));
|
||||||
|
};
|
||||||
|
xhr.onerror = () => {
|
||||||
|
console.error(`[DW] S3 PUT ${item.name} network error`);
|
||||||
|
reject(new Error('Network error — check console for details'));
|
||||||
|
};
|
||||||
xhr.send(item.file);
|
xhr.send(item.file);
|
||||||
});
|
});
|
||||||
document.getElementById(`fpb-${idx}`).style.width = '100%';
|
document.getElementById(`fpb-${idx}`).style.width = '100%';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue