23 / resumable.js

A JavaScript library for providing multiple simultaneous, stable, fault-tolerant and resumable/restartable uploads via the HTML5 File API.
MIT License
4.64k stars 612 forks source link

Writing Empty files #378

Open vaskaloidis opened 7 years ago

vaskaloidis commented 7 years ago

Does anybody know why resumable.js might be writing empty (0kb) files for me - it was previously uploading the full file but now the file generated is 0kb, and I cannot figure out why. It goes through the full upload process, but the file getting written is empty.

cpnielsen commented 7 years ago

Does the network requests contain data and the right number of chunks?

vaskaloidis commented 7 years ago

Its not because its not iterating over the data from the input stream.

InputStream pis = request.getPortletInputStream(); //This must be empty now
long readed = 0;
long content_length = request.getContentLength();
log.info("Content Length: " + content_length); //Always -1
byte[] bytes = new byte[1024 * 100];
while(readed < content_length) {
// Not getting into the loop even
}

This used to work - I am not sure what I changed to cause the input stream to be empty

cpnielsen commented 7 years ago

We do not provide support on any backend/receiving code, only the frontend library, as it can any of a 1000 constellations, code, server setup, etc.

vaskaloidis commented 7 years ago

Its not backend - the request from resumable.js used to contain an input stream with the file chunks, now its not. Resumable.js is not sending data to the backend anymore (it used to).

cpnielsen commented 7 years ago

Can you verify, in a browser or via network sniffer (WireShark, Fiddler, etc.) that the requests contain no data?

vaskaloidis commented 7 years ago

When I write the contents of the request.getPortletInputStream() to console - its empty now. Again, this previously worked

InputStream pis = request.getPortletInputStream(); //This is empty now
br = new BufferedReader(new InputStreamReader(pis));
while ((line = br.readLine()) != null) {
    sb.append(line);
}

This is printing out nothing.

cpnielsen commented 7 years ago

@vaskaloidis Again, I cannot tell why the data is not reaching your backend and I cannot help you debug that part. Did you update to a new version of Resumable.js that caused this change? Otherwise it sounds like it's an issue with your server setup.

mmrosatab commented 3 years ago

@vaskaloidis I had this same problem of empty inputstream when I put testMethod: 'POST', the server side receives the various parameters normally in the request, such as chunck number, chunck size, etc., but the inputstream is always empty for me. Using testMethod: 'GET' the inputstream comes with the data, however smoothing the network tab in the browser I notice that the requests fail a lot, although the file upload is completed correctly. This question has been open for many years, but perhaps this information will be useful to someone. ** EDIT: The errors in the requests using testMethod: 'GET' were because I had only implemented the POST method on the server side. After I implemented the GET method on the server side that return a response status 204 errors did not occur.