@@ -7,6 +7,7 @@ var shallowClone = require('../utils').shallowClone;
7
7
var toError = require ( '../utils' ) . toError ;
8
8
var util = require ( 'util' ) ;
9
9
var executeLegacyOperation = require ( '../utils' ) . executeLegacyOperation ;
10
+ const deprecateOptions = require ( '../utils' ) . deprecateOptions ;
10
11
11
12
var DEFAULT_GRIDFS_BUCKET_OPTIONS = {
12
13
bucketName : 'fs' ,
@@ -79,21 +80,28 @@ util.inherits(GridFSBucket, Emitter);
79
80
* @param {object } [options.metadata] Optional object to store in the file document's `metadata` field
80
81
* @param {string } [options.contentType] Optional string to store in the file document's `contentType` field
81
82
* @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
83
84
* @return {GridFSBucketWriteStream }
84
85
*/
85
86
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 ) ;
94
103
}
95
- return new GridFSBucketWriteStream ( this , filename , options ) ;
96
- } ;
104
+ ) ;
97
105
98
106
/**
99
107
* Returns a writable stream (GridFSBucketWriteStream) for writing
@@ -107,25 +115,32 @@ GridFSBucket.prototype.openUploadStream = function(filename, options) {
107
115
* @param {object } [options.metadata] Optional object to store in the file document's `metadata` field
108
116
* @param {string } [options.contentType] Optional string to store in the file document's `contentType` field
109
117
* @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
111
119
* @return {GridFSBucketWriteStream }
112
120
*/
113
121
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
+ }
120
134
121
- if ( ! options . chunkSizeBytes ) {
122
- options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
123
- }
135
+ if ( ! options . chunkSizeBytes ) {
136
+ options . chunkSizeBytes = this . s . options . chunkSizeBytes ;
137
+ }
124
138
125
- options . id = id ;
139
+ options . id = id ;
126
140
127
- return new GridFSBucketWriteStream ( this , filename , options ) ;
128
- } ;
141
+ return new GridFSBucketWriteStream ( this , filename , options ) ;
142
+ }
143
+ ) ;
129
144
130
145
/**
131
146
* Returns a readable stream (GridFSBucketReadStream) for streaming file
0 commit comments