当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript gridfs-stream.default函数代码示例

本文整理汇总了TypeScript中gridfs-stream.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

		fs.open (filepath, 'r', function (err, fd) {
			if (!err) {
				// File already exits
				fs.closeSync (fd);
				resolve (null);
			}
			else {
				// File does not exist...create it
				var fs_write_stream = fs.createWriteStream (filepath);

				var gfs = Grid(conn.db);

				//read from mongodb
				var readstream = gfs.createReadStream ({_id: file._id});
				readstream.pipe (fs_write_stream);
				fs_write_stream.on ('close', function () {
					console.log ('file created: ' + filepath);
					resolve (null);
				});
				fs_write_stream.on ('error', function () {
					err = 'file creation error: ' + filepath;
					reject (err);
				});
			}
		});
开发者ID:roderickmonk,项目名称:rod-monk-sample-repo,代码行数:25,代码来源:ttcGridFS.ts

示例2: Grid

 collection.findOne({filename: request.params.name}, (error:any, item:any):void => {
     if (!error) {
         if (item) {
             var gfs = Grid(conn.db, mongoose.mongo); //missing parameter
             if (gfs) {
                 var readstream = gfs.createReadStream({filename: request.params.name});
                 if (readstream) {
                     readstream.pipe(response);
                     readstream.on('close', (file:any):void => {
                         conn.db.close();
                         logger.trace("end /file/:name");
                     });
                 } else {
                     conn.db.close();
                     logger.error("/file/:name 1");
                     next();
                 }
             } else {
                 conn.db.close();
                 logger.error("/file/:name 2");
                 next();
             }
         } else {
             conn.db.close();
             logger.error("/file/:name 3");
             next();
         }
     } else {
         conn.db.close();
         logger.error("/file/:name 4");
         next();
     }
 });
开发者ID:7thCode,项目名称:wmonsin,代码行数:33,代码来源:file_controller.ts

示例3: Promise

	return new Promise (function (resolve, reject) {
	
		var gfs = Grid(conn.db);
		gfs.remove ({_id : file._id}, function (err) {
			err ? reject (err) : resolve (null);
		});
	});
开发者ID:roderickmonk,项目名称:rod-monk-sample-repo,代码行数:7,代码来源:ttcGridFS.ts

示例4: Promise

		new Promise((resolve, reject) => {

			const gfs = Grid(conn.db);
			const writestream = gfs.createWriteStream({
				_id: new ObjectID(),
				filename: filename,
				metadata: { collection_id: collection_id, category: category }
			});
			fs.createReadStream(filepath).pipe(writestream);

			writestream.on('close', (file: any) => resolve(null));
		});
开发者ID:roderickmonk,项目名称:rod-monk-sample-repo-ng2,代码行数:12,代码来源:GridFS.ts


注:本文中的gridfs-stream.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。