當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。