|
|
@@ -185,7 +185,7 @@ class MyUploadAdapter {
|
|
|
return new Promise( ( resolve, reject ) => {
|
|
|
this._initRequest();
|
|
|
this._initListeners( resolve, reject );
|
|
|
- this._sendRequest();
|
|
|
+ this._sendRequest( reject );
|
|
|
} );
|
|
|
}
|
|
|
|
|
|
@@ -292,18 +292,23 @@ class MyUploadAdapter {
|
|
|
// ...
|
|
|
|
|
|
// Prepares the data and sends the request.
|
|
|
- _sendRequest() {
|
|
|
- // Prepare the form data.
|
|
|
- const data = new FormData();
|
|
|
- data.append( 'upload', this.loader.file );
|
|
|
-
|
|
|
- // Important note: This is the right place to implement security mechanisms
|
|
|
- // like authentication and CSRF protection. For instance, you can use
|
|
|
- // XMLHttpRequest.setRequestHeader() to set the request headers containing
|
|
|
- // the CSRF token generated earlier by your application.
|
|
|
-
|
|
|
- // Send the request.
|
|
|
- this.xhr.send( data );
|
|
|
+ _sendRequest( reject ) {
|
|
|
+ this.loader.file
|
|
|
+ .then( file => {
|
|
|
+ // Prepare the form data.
|
|
|
+ const data = new FormData();
|
|
|
+
|
|
|
+ data.append( 'upload', file );
|
|
|
+
|
|
|
+ // Important note: This is the right place to implement security mechanisms
|
|
|
+ // like authentication and CSRF protection. For instance, you can use
|
|
|
+ // XMLHttpRequest.setRequestHeader() to set the request headers containing
|
|
|
+ // the CSRF token generated earlier by your application.
|
|
|
+
|
|
|
+ // Send the request.
|
|
|
+ this.xhr.send( data );
|
|
|
+ } )
|
|
|
+ .catch( reject );
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
@@ -414,7 +419,7 @@ class MyUploadAdapter {
|
|
|
return new Promise( ( resolve, reject ) => {
|
|
|
this._initRequest();
|
|
|
this._initListeners( resolve, reject );
|
|
|
- this._sendRequest();
|
|
|
+ this._sendRequest( reject );
|
|
|
} );
|
|
|
}
|
|
|
|
|
|
@@ -481,18 +486,23 @@ class MyUploadAdapter {
|
|
|
}
|
|
|
|
|
|
// Prepares the data and sends the request.
|
|
|
- _sendRequest() {
|
|
|
- // Prepare the form data.
|
|
|
- const data = new FormData();
|
|
|
- data.append( 'upload', this.loader.file );
|
|
|
-
|
|
|
- // Important note: This is the right place to implement security mechanisms
|
|
|
- // like authentication and CSRF protection. For instance, you can use
|
|
|
- // XMLHttpRequest.setRequestHeader() to set the request headers containing
|
|
|
- // the CSRF token generated earlier by your application.
|
|
|
-
|
|
|
- // Send the request.
|
|
|
- this.xhr.send( data );
|
|
|
+ _sendRequest( reject ) {
|
|
|
+ this.loader.file
|
|
|
+ .then( file => {
|
|
|
+ // Prepare the form data.
|
|
|
+ const data = new FormData();
|
|
|
+
|
|
|
+ data.append( 'upload', file );
|
|
|
+
|
|
|
+ // Important note: This is the right place to implement security mechanisms
|
|
|
+ // like authentication and CSRF protection. For instance, you can use
|
|
|
+ // XMLHttpRequest.setRequestHeader() to set the request headers containing
|
|
|
+ // the CSRF token generated earlier by your application.
|
|
|
+
|
|
|
+ // Send the request.
|
|
|
+ this.xhr.send( data );
|
|
|
+ } )
|
|
|
+ .catch( reject );
|
|
|
}
|
|
|
}
|
|
|
|