Server Id is concatenated to the load url
shija-ntula opened this issue · 3 comments
Hi there.
It's greet to have you crafted such a greet JS library.
Big thanks.
By the way, I've got some problems connecting my frontend FilePond to my server for loading already uploaded files.
Here is my server options
FilePond.setOptions({
server: {
url: "URL",
timeout: 7000,
process: {
url: '/upload',
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
},
withCredentials: false,
// onload: (response) => response.key,
onerror: (response) => response.data,
ondata: (formData) => {
formData.append('Hello', 'World');
return formData;
},
},
revert: '/delete',
load: '/load',
},
});
And here I'm adding my files from server
var images = JSON.parse(`<?= json_encode($images) ?>`);
$('.my-pond').filepond();
$('.my-pond').filepond('allowMultiple', true);
$('.my-pond').filepond('maxFiles', 6);
$('.my-pond').filepond('maxFileSize', '500KB');
$('.my-pond').filepond('acceptedFileTypes', ['image/png', 'image/jpeg'],);
if(images.length > 0){
$('.my-pond').filepond('files', images);
}
Here is the formatting of images in my controller (php) before passed to JS
$images = [];
if($radiology->images){
foreach ($radiology->images as $image) {
$images[] = [
'source' => $image,
'options' => [
'type' => 'local',
],
];
}
}
But The file is not loaded, showing error:
And loking into Chrome console, I find the ID concatenated at the end of load url:
http://127.0.0.1:8000/filepond/ct-scans%255EMGR-2021-07-00001/loadMGR-2021-07-00001-RafPd39mIG7ls0w5.jpg
The load url end at load
and the server id is MGR-2021-07-00001-RafPd39mIG7ls0w5.jpg
We require the issue template to be filled out on all new issues. The issue template helps us collect all the information we need to address your submission efficiently.
If your issue can be classified as an integration question or a question about specific features of FilePond we ask you kindly to submit it on Stack Overflow.
We will be able to more closely look at your issue once the issue template has been filled out. The issue will be closed until the above is addressed.
Please leave a comment after you've updated the issue.
In fact I've fixed the issue by adding a query param to the load url,
LIKE
revert: '/delete',
load: '/load?serverId=',
and after the concatenation it works.
Although I feel like this is a hackish fix.
Thanks anyway.
This is in the server docs.
About the load method:
https://pqina.nl/filepond/docs/api/server/#load
About the URL:
https://pqina.nl/filepond/docs/api/server/#url