Skip to content

Commit

Permalink
Fix uploadValidator example
Browse files Browse the repository at this point in the history
Previous code sample had race condition; see #62.

Added note that the "saved" event can be used to move the file.
  • Loading branch information
sffc committed Aug 8, 2018
1 parent bd3c771 commit 4cfeeee
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions README.md
Expand Up @@ -460,15 +460,12 @@ Can be overridden to enable async validation and preparing.

```javascript
uploader.uploadValidator = function(event, callback){
fs.mkdtemp('/tmp/foo-', function(err, folder) {
if (err) {
callback( false ); // abort
}
else {
uploader.dir = folder;
callback( true ); // ready
}
});
// asynchronous operations allowed here; when done,
if (/* success */) {
callback(true);
} else {
callback(false);
}
};
```

Expand Down Expand Up @@ -514,6 +511,8 @@ The transmission of a file is complete.

A file has been saved. It is recommended that you check `event.file.success` to tell whether or not the file was saved without errors.

In this event, you can safely move the saved file to a new location.

##### Event Properties

* `event.file` The same file object that would have been passed during the `start` event earlier.
Expand Down

0 comments on commit 4cfeeee

Please sign in to comment.