javascript - Store files in mongodb with Nodejs -
i saving files on fs of server , want save them in mongodb.(for easier backup , stuff).i want store files 4-5mb maximum , tried save them mongoose buffer type.i saved them , retrieved them noticed significant slow performance when save , retrieve files 4 or 5mb.
my schema:
let fileschema = new schema({ name: {type: string, required: true}, _announcement: {type: schema.types.objectid, ref: 'announcements'}, data: buffer, contenttype: string });
how retrieve them expressjs server:
let name = encodeuricomponent(file.name); res.writehead(200, { 'content-type': file.contenttype, 'content-disposition': 'attachment;filename*=utf-8\'\'' + name }); res.write(new buffer(file.data));
my question should use zlib compress functions 'deflate' compress buffer before saving them in mongodb , uncompress binary before sending them client? make whole proccess faster?am missing something?
Comments
Post a Comment