This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

View File

@@ -7,6 +7,7 @@ var shallowClone = require('../utils').shallowClone;
var toError = require('../utils').toError;
var util = require('util');
var executeLegacyOperation = require('../utils').executeLegacyOperation;
const deprecateOptions = require('../utils').deprecateOptions;
var DEFAULT_GRIDFS_BUCKET_OPTIONS = {
bucketName: 'fs',
@@ -79,21 +80,28 @@ util.inherits(GridFSBucket, Emitter);
* @param {object} [options.metadata] Optional object to store in the file document's `metadata` field
* @param {string} [options.contentType] Optional string to store in the file document's `contentType` field
* @param {array} [options.aliases] Optional array of strings to store in the file document's `aliases` field
* @param {boolean} [options.disableMD5=false] If true, disables adding an md5 field to file data
* @param {boolean} [options.disableMD5=false] **Deprecated** If true, disables adding an md5 field to file data
* @return {GridFSBucketWriteStream}
*/
GridFSBucket.prototype.openUploadStream = function(filename, options) {
if (options) {
options = shallowClone(options);
} else {
options = {};
GridFSBucket.prototype.openUploadStream = deprecateOptions(
{
name: 'GridFSBucket.openUploadStream',
deprecatedOptions: ['disableMD5'],
optionsIndex: 1
},
function(filename, options) {
if (options) {
options = shallowClone(options);
} else {
options = {};
}
if (!options.chunkSizeBytes) {
options.chunkSizeBytes = this.s.options.chunkSizeBytes;
}
return new GridFSBucketWriteStream(this, filename, options);
}
if (!options.chunkSizeBytes) {
options.chunkSizeBytes = this.s.options.chunkSizeBytes;
}
return new GridFSBucketWriteStream(this, filename, options);
};
);
/**
* Returns a writable stream (GridFSBucketWriteStream) for writing
@@ -107,25 +115,32 @@ GridFSBucket.prototype.openUploadStream = function(filename, options) {
* @param {object} [options.metadata] Optional object to store in the file document's `metadata` field
* @param {string} [options.contentType] Optional string to store in the file document's `contentType` field
* @param {array} [options.aliases] Optional array of strings to store in the file document's `aliases` field
* @param {boolean} [options.disableMD5=false] If true, disables adding an md5 field to file data
* @param {boolean} [options.disableMD5=false] **Deprecated** If true, disables adding an md5 field to file data
* @return {GridFSBucketWriteStream}
*/
GridFSBucket.prototype.openUploadStreamWithId = function(id, filename, options) {
if (options) {
options = shallowClone(options);
} else {
options = {};
GridFSBucket.prototype.openUploadStreamWithId = deprecateOptions(
{
name: 'GridFSBucket.openUploadStreamWithId',
deprecatedOptions: ['disableMD5'],
optionsIndex: 2
},
function(id, filename, options) {
if (options) {
options = shallowClone(options);
} else {
options = {};
}
if (!options.chunkSizeBytes) {
options.chunkSizeBytes = this.s.options.chunkSizeBytes;
}
options.id = id;
return new GridFSBucketWriteStream(this, filename, options);
}
if (!options.chunkSizeBytes) {
options.chunkSizeBytes = this.s.options.chunkSizeBytes;
}
options.id = id;
return new GridFSBucketWriteStream(this, filename, options);
};
);
/**
* Returns a readable stream (GridFSBucketReadStream) for streaming file