Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Have you updated FilePond and its plugins?
- I have updated FilePond and its plugins
Describe the bug
In my current implementation, files uploaded via FilePond are processed and sent to the server automatically and in a random order. This behavior is undesirable when files need to be uploaded sequentially, based on a specific order (e.g., alphabetical, numerical, or based on user-defined parameters).
This is my code:
`
let audiobookId = {{$audiobook->id}};
@if(isset($uploadedFiles))
const uploadedFiles = @json($uploadedFiles);
@else
const uploadedFiles = [];
@endif
const pond = FilePond.create(
document.getElementById('{{$name}}'),
{
itemInsertLocation: (a, b) => {
if (!(a.name && b.name)) return 0;
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
}
return 0;
},
files: uploadedFiles
.map(file => ({
source: file.id,
options: {
type: 'local',
file: {
name: file.name,
id: file.id,
size: file.size,
type: file.type
},
metadata: {
poster: file.url
}
}
})),
credits: false,
onremovefile: (error, file) => {
if (!error) {
const mediaId = file.serverId;
fetch('{{ route("audiobooks.deleteMedia", ":id") }}'.replace(':id', mediaId), {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: mediaId }),
})
.then(response => response.json())
.then(data => {
console.log('File removed successfully:', data);
})
.catch(error => {
console.error('Error removing file:', error);
});
}
},
onprocessfilerevert: (file) => {
const mediaId = file.serverId;
fetch('{{ route("audiobooks.deleteMedia", ":id") }}'.replace(':id', mediaId), {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: mediaId }),
})
.then(response => response.json())
.then(data => {
console.log('File removed successfully:', data);
})
.catch(error => {
console.error('Error removing file:', error);
});
},
server: {
process: {
url: '{{ route("audiobooks.uploadMedia", ":id") }}'.replace(':id', audiobookId),
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}
}
}
);`
Reproduction
No Reproduction
Environment
- Device: Any
- OS: Any
- Browser: Any
Metadata
Metadata
Assignees
Labels
No labels