Hi has anyone tried to use FilePond with Laravel to upload files in chunks ?
I am trying to do that but I dont know how to get the content of a PATCH method.
The upload starts, and a receive a bunch of PATCH methods, I see (Network Tab in Dev Mode Firefox) that they are different, because the offset changes.
Let me know if you need more details to help me.
My blade view (where the js is located):
<form action="{{ route('upload.store') }}" enctype="multipart/form-data"
method="post">
@csrf
<input class="" id="imageUploadFilePond" name="file" type="file">
<button class="btn btn-primary" type="submit">Submit</button>
</form>
@push('scripts')
<script src="https://unpkg.com/filepond@^4/dist/filepond.js"></script>
<script>
const inputElement = document.querySelector('#imageUploadFilePond');
const pond = FilePond.create(inputElement, {
server: {
url: '/upload',
patch: "/",
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
},
chunkUploads: true,
chunkSize: 1048576,
chunkForce: true,
});
</script>
@endpush
In my UploadController.php my methods :
public function store(Request $request)
{
if ($request->file === '{}') {
return uniqid();
}
return '';
}
public function update(Request $request, $id)
{
$uploadOffset = $request->header('upload-offset');
$uploadLenght = $request->header('upload-length');
$uploadName = $request->header('upload-name');
$numberOfChunks = $uploadLenght / self::CHUNKSIZE;
$currentChunk = $uploadOffset / self::CHUNKSIZE;
return $id;
}