Fix upload.html: camelCase multipart params, filename field, ETag/partNumber, s3Key/assetId tracking
This commit is contained in:
parent
31ca999075
commit
1862082ba7
1 changed files with 25 additions and 12 deletions
|
|
@ -622,6 +622,8 @@
|
|||
status: 'waiting',
|
||||
progress: 0,
|
||||
uploadId: null,
|
||||
s3Key: null,
|
||||
assetId: null,
|
||||
uploadedBytes: 0,
|
||||
};
|
||||
|
||||
|
|
@ -747,8 +749,9 @@
|
|||
async function simpleUploadFile(item) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', item.file);
|
||||
formData.append('project_id', uploadState.selectedProject);
|
||||
formData.append('bin_id', uploadState.selectedBin);
|
||||
formData.append('filename', item.file.name);
|
||||
formData.append('projectId', uploadState.selectedProject);
|
||||
formData.append('binId', uploadState.selectedBin);
|
||||
|
||||
const result = await simpleUpload(formData);
|
||||
if (!result.success) {
|
||||
|
|
@ -766,16 +769,20 @@
|
|||
// Initialize upload
|
||||
const initResult = await initUpload({
|
||||
filename: fileName,
|
||||
content_type: file.type,
|
||||
project_id: uploadState.selectedProject,
|
||||
bin_id: uploadState.selectedBin,
|
||||
fileSize: file.size,
|
||||
contentType: file.type,
|
||||
projectId: uploadState.selectedProject,
|
||||
binId: uploadState.selectedBin,
|
||||
});
|
||||
|
||||
if (!initResult.success) {
|
||||
throw new Error('Failed to initialize upload');
|
||||
}
|
||||
|
||||
item.uploadId = initResult.data.upload_id;
|
||||
const { uploadId, key, assetId } = initResult.data;
|
||||
item.uploadId = uploadId;
|
||||
item.s3Key = key;
|
||||
item.assetId = assetId;
|
||||
const parts = [];
|
||||
const totalChunks = Math.ceil(file.size / chunkSize);
|
||||
|
||||
|
|
@ -787,9 +794,9 @@
|
|||
|
||||
const formData = new FormData();
|
||||
formData.append('file', chunk);
|
||||
formData.append('uploadId', item.uploadId);
|
||||
formData.append('uploadId', uploadId);
|
||||
formData.append('partNumber', i + 1);
|
||||
formData.append('key', fileName);
|
||||
formData.append('key', key);
|
||||
|
||||
const chunkResult = await uploadPart(formData);
|
||||
if (!chunkResult.success) {
|
||||
|
|
@ -797,8 +804,8 @@
|
|||
}
|
||||
|
||||
parts.push({
|
||||
part_number: i + 1,
|
||||
etag: chunkResult.data.etag,
|
||||
partNumber: i + 1,
|
||||
ETag: chunkResult.data.etag,
|
||||
});
|
||||
|
||||
item.uploadedBytes = end;
|
||||
|
|
@ -808,7 +815,9 @@
|
|||
|
||||
// Complete upload
|
||||
const completeResult = await completeUpload({
|
||||
upload_id: item.uploadId,
|
||||
uploadId,
|
||||
key,
|
||||
assetId,
|
||||
parts,
|
||||
});
|
||||
|
||||
|
|
@ -832,7 +841,11 @@
|
|||
if (!item) return;
|
||||
|
||||
if (item.uploadId) {
|
||||
abortUpload({ upload_id: item.uploadId }).catch(console.error);
|
||||
abortUpload({
|
||||
uploadId: item.uploadId,
|
||||
key: item.s3Key,
|
||||
assetId: item.assetId,
|
||||
}).catch(console.error);
|
||||
}
|
||||
|
||||
uploadState.uploadQueue = uploadState.uploadQueue.filter(u => u.id !== id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue