Priority Queue
Prioritize file uploads by sorting tasks before uploading. Smaller files upload first in this example, but you can implement any priority logic in onSelect.
new MultipleUpload(document.getElementById('demo-priority'), {
uploadUrl: '/api/upload',
multiple: true,
autoUpload: false,
concurrency: 1,
onSelect: function(files) {
// Sort smallest files first (priority = smaller)
var sorted = Array.from(files).sort(function(a, b) {
return a.size - b.size;
});
var log = document.getElementById('priority-log');
log.innerHTML = '<div>Upload order (smallest first):</div>';
sorted.forEach(function(f, i) {
log.innerHTML += '<div>' + (i + 1) + '. ' + f.name +
' (' + MultipleUpload.formatSize(f.size) + ')</div>';
});
return sorted;
},
onInit: function(uploader) {
// Add upload button after selection
var btn = document.createElement('button');
btn.textContent = 'Upload (Priority Order)';
btn.style.cssText = 'margin-top:12px; padding:8px 20px; background:#0891b2; color:#fff; border:none; border-radius:6px; cursor:pointer;';
btn.addEventListener('click', function() { uploader.upload(); });
uploader.container.appendChild(btn);
}
});
Order and parallelism together
concurrency decides how many files move at once; priority decides which ones get those slots. Together they answer the real question with a long queue — not just how fast, but what the user sees finish first.
The perception matters as much as the throughput
Finishing the file the user is waiting to look at, ahead of forty they will never open individually, makes the same total upload feel dramatically shorter. Nothing about the bytes changed; the ordering did.