@@ -7,6 +7,7 @@ var shallowClone = require('../utils').shallowClone;
77var toError = require ( '../utils' ) . toError ;
88var util = require ( 'util' ) ;
99var executeLegacyOperation = require ( '../utils' ) . executeLegacyOperation ;
10+ const deprecateOptions = require ( '../utils' ) . deprecateOptions ;
1011
1112var DEFAULT_GRIDFS_BUCKET_OPTIONS = {
1213 bucketName : 'fs' ,
@@ -79,21 +80,28 @@ util.inherits(GridFSBucket, Emitter);
7980 * @param {object } [options.metadata] Optional object to store in the file document's `metadata` field
8081 * @param {string } [options.contentType] Optional string to store in the file document's `contentType` field
8182 * @param {array } [options.aliases] Optional array of strings to store in the file document's `aliases` field
82- * @param {boolean } [options.disableMD5=false] If true, disables adding an md5 field to file data
83+ * @param {boolean } [options.disableMD5=false] **Deprecated** If true, disables adding an md5 field to file data
8384 * @return {GridFSBucketWriteStream }
8485 */
8586
86- GridFSBucket . prototype . openUploadStream = function ( filename , options ) {
87- if ( options ) {
88- options = shallowClone ( options ) ;
89- } else {
90- options = { } ;
91- }
92- if ( ! options . chunkSizeBytes ) {
93- options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
87+ GridFSBucket . prototype . openUploadStream = deprecateOptions (
88+ {
89+ name : 'GridFSBucket.openUploadStream' ,
90+ deprecatedOptions : [ 'disableMD5' ] ,
91+ optionsIndex : 1
92+ } ,
93+ function ( filename , options ) {
94+ if ( options ) {
95+ options = shallowClone ( options ) ;
96+ } else {
97+ options = { } ;
98+ }
99+ if ( ! options . chunkSizeBytes ) {
100+ options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
101+ }
102+ return new GridFSBucketWriteStream ( this , filename , options ) ;
94103 }
95- return new GridFSBucketWriteStream ( this , filename , options ) ;
96- } ;
104+ ) ;
97105
98106/**
99107 * Returns a writable stream (GridFSBucketWriteStream) for writing
@@ -107,25 +115,32 @@ GridFSBucket.prototype.openUploadStream = function(filename, options) {
107115 * @param {object } [options.metadata] Optional object to store in the file document's `metadata` field
108116 * @param {string } [options.contentType] Optional string to store in the file document's `contentType` field
109117 * @param {array } [options.aliases] Optional array of strings to store in the file document's `aliases` field
110- * @param {boolean } [options.disableMD5=false] If true, disables adding an md5 field to file data
118+ * @param {boolean } [options.disableMD5=false] **Deprecated** If true, disables adding an md5 field to file data
111119 * @return {GridFSBucketWriteStream }
112120 */
113121
114- GridFSBucket . prototype . openUploadStreamWithId = function ( id , filename , options ) {
115- if ( options ) {
116- options = shallowClone ( options ) ;
117- } else {
118- options = { } ;
119- }
122+ GridFSBucket . prototype . openUploadStreamWithId = deprecateOptions (
123+ {
124+ name : 'GridFSBucket.openUploadStreamWithId' ,
125+ deprecatedOptions : [ 'disableMD5' ] ,
126+ optionsIndex : 2
127+ } ,
128+ function ( id , filename , options ) {
129+ if ( options ) {
130+ options = shallowClone ( options ) ;
131+ } else {
132+ options = { } ;
133+ }
120134
121- if ( ! options . chunkSizeBytes ) {
122- options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
123- }
135+ if ( ! options . chunkSizeBytes ) {
136+ options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
137+ }
124138
125- options . id = id ;
139+ options . id = id ;
126140
127- return new GridFSBucketWriteStream ( this , filename , options ) ;
128- } ;
141+ return new GridFSBucketWriteStream ( this , filename , options ) ;
142+ }
143+ ) ;
129144
130145/**
131146 * Returns a readable stream (GridFSBucketReadStream) for streaming file
0 commit comments