pqina / filepond

🌊 A flexible and fun JavaScript file upload library
https://pqina.nl/filepond
MIT License
15.15k stars 825 forks source link

Process chunks in the case of failure #491

Open meness opened 4 years ago

meness commented 4 years ago

Docs say if chunks failed, the client requests HEAD and the server must return Upload-Offset: <offset>, then the client mark lower chunks as completed, but in my case, the client starts from 0 once again while I send the header with a right offset.

React

<FilePond
          imageCropAspectRatio="1:1"
          stylePanelLayout="compact circle"
          maxFileSize="5MB"
          instantUpload={false}
          chunkUploads
          chunkForce
          chunkSize={500000}
          styleLoadIndicatorPosition="center bottom"
          acceptedFileTypes={['image/jpeg', 'image/png', 'image/webp']}
          styleButtonRemoveItemPosition="center bottom"
        />

Express

res.setHeader('Upload-Offset', offset);
  res.send();

My test is: I write 500000 bytes then throw an error. When the client requests a HEAD I tell it the offset is 500000, but it starts from 0.

I use the latest version.

rikschennink commented 4 years ago

I don't have time to test this right now, so if you have any ideas what could be causing the issue that would be very helpful

BuchholzTim commented 4 years ago

@meness Did you find a workaround or a solution to your problem? I'm currently facing the same problem, with the only difference being, that I'm using the VUE-Adapter instead of React.

BuchholzTim commented 4 years ago

So I debugged it today to see what exactly is happening and filepond is in fact working correctly.

In my case it was an error caused by ExpressJS in the backend, because I didn't set: res.set('Access-Control-Expose-Headers', 'Upload-Offset');

Filepond received null, when trying to read the response header by xhr.getResponseHeader("Upload-Offset") and defaulted to using 0 as Offset.