@@ -511,7 +511,7 @@ module.exports = function(AV) {
511
511
* @param {UploadProgressCallback } [options.onprogress] 文件上传进度,在 Node.js 中无效,回调参数说明详见 {@link UploadProgressCallback}。
512
512
* @return {Promise } Promise that is resolved when the save finishes.
513
513
*/
514
- save ( options ) {
514
+ save ( options = { } ) {
515
515
if ( this . id ) {
516
516
throw new Error (
517
517
'File already saved. If you want to manipulate a file, use AV.Query to get it.'
@@ -555,14 +555,22 @@ module.exports = function(AV) {
555
555
throw new TypeError ( 'malformed file data' ) ;
556
556
} )
557
557
. then ( data => {
558
+ const _options = _ . extend ( { } , options ) ;
559
+ // filter out download progress events
560
+ if ( options . onprogress ) {
561
+ _options . onprogress = event => {
562
+ if ( event . direction === 'download' ) return ;
563
+ return options . onprogress ( event ) ;
564
+ } ;
565
+ }
558
566
switch ( uploadInfo . provider ) {
559
567
case 's3' :
560
- return s3 ( uploadInfo , data , this , options ) ;
568
+ return s3 ( uploadInfo , data , this , _options ) ;
561
569
case 'qcloud' :
562
- return cos ( uploadInfo , data , this , options ) ;
570
+ return cos ( uploadInfo , data , this , _options ) ;
563
571
case 'qiniu' :
564
572
default :
565
- return qiniu ( uploadInfo , data , this , options ) ;
573
+ return qiniu ( uploadInfo , data , this , _options ) ;
566
574
}
567
575
} )
568
576
. then ( tap ( ( ) => this . _callback ( true ) ) , error => {
0 commit comments