Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort uplpoading file. #95

Closed
tungbk52 opened this issue Jan 21, 2015 · 4 comments
Closed

Abort uplpoading file. #95

tungbk52 opened this issue Jan 21, 2015 · 4 comments

Comments

@tungbk52
Copy link

I'm using follow code to upload file to node js server run multer

function uploadFiles(url, files) {
  var formData = new FormData();

  for (var i = 0, file; file = files[i]; ++i) {
    formData.append(file.name, file);
  }

  var xhr = new XMLHttpRequest();
  xhr.open('POST', url, true);
  xhr.onload = function(e) { ... };

  xhr.send(formData);  // multipart/form-data
}

Now, on client I want abort uploading file use xhr.abort(), multer not continous save data, but client can't not upload more any file.

@jpfluger
Copy link
Contributor

jpfluger commented May 1, 2015

Currently not a clean method to do this. I'd like to see smoother responsiveness with client requests myself.

@LinusU
Copy link
Member

LinusU commented May 1, 2015

As I understand the spec the .abort() function will close the socket which we will detect on our end, and no more data will come thru. We won't be able to send any response since the socket will be closed.

I don't really understand your last sentence, are you saying that multer can't handle anymore requests after one client runs .abort()?

@jpfluger
Copy link
Contributor

jpfluger commented May 1, 2015

@LinusU is correct. The client-server connection will be closed on xhr.abort(). My apologies. I looked at the code example as being server-side code and trying to abort multer in progress. multer.abort() does not exist. Actually, xhr.abort() could play into the per-file strategy in our discussion for #128.

@LinusU
Copy link
Member

LinusU commented Jul 18, 2015

As I said in my previous comment xhr.abort closes the socket and we won't be able to send any response at all. Please reopen if you have further clarifications/questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants