@@ -511,7 +511,7 @@ module.exports = function(AV) {
511511 * @param {UploadProgressCallback } [options.onprogress] 文件上传进度,在 Node.js 中无效,回调参数说明详见 {@link UploadProgressCallback}。
512512 * @return {Promise } Promise that is resolved when the save finishes.
513513 */
514- save ( options ) {
514+ save ( options = { } ) {
515515 if ( this . id ) {
516516 throw new Error (
517517 'File already saved. If you want to manipulate a file, use AV.Query to get it.'
@@ -555,14 +555,22 @@ module.exports = function(AV) {
555555 throw new TypeError ( 'malformed file data' ) ;
556556 } )
557557 . 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+ }
558566 switch ( uploadInfo . provider ) {
559567 case 's3' :
560- return s3 ( uploadInfo , data , this , options ) ;
568+ return s3 ( uploadInfo , data , this , _options ) ;
561569 case 'qcloud' :
562- return cos ( uploadInfo , data , this , options ) ;
570+ return cos ( uploadInfo , data , this , _options ) ;
563571 case 'qiniu' :
564572 default :
565- return qiniu ( uploadInfo , data , this , options ) ;
573+ return qiniu ( uploadInfo , data , this , _options ) ;
566574 }
567575 } )
568576 . then ( tap ( ( ) => this . _callback ( true ) ) , error => {
0 commit comments