Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(crowi) {
const Uploader = require('./uploader');
const lib = new Uploader(crowi);
const COLLECTION_NAME = 'attachmentFiles';
// const CHUNK_COLLECTION_NAME = `${COLLECTION_NAME}.chunks`;
// instantiate mongoose-gridfs
const { createModel } = require('mongoose-gridfs');
const AttachmentFile = createModel({
modelName: COLLECTION_NAME,
bucketName: COLLECTION_NAME,
connection: mongoose.connection,
});
// get Collection instance of chunk
// const chunkCollection = mongoose.connection.collection(CHUNK_COLLECTION_NAME);
// create promisified method
AttachmentFile.promisifiedWrite = util.promisify(AttachmentFile.write).bind(AttachmentFile);
AttachmentFile.promisifiedUnlink = util.promisify(AttachmentFile.unlink).bind(AttachmentFile);
lib.isValidUploadSettings = function() {
return true;
};
lib.deleteFile = async function(attachment) {