add-file-to-drive - バッファ受け付けを削除
This commit is contained in:
		
							parent
							
								
									342345cc2f
								
							
						
					
					
						commit
						519bb82b03
					
				
					 1 changed files with 2 additions and 13 deletions
				
			
		| 
						 | 
					@ -36,7 +36,7 @@ const addToGridFS = (name: string, readable: stream.Readable, type: string, meta
 | 
				
			||||||
 * Add file to drive
 | 
					 * Add file to drive
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param user User who wish to add file
 | 
					 * @param user User who wish to add file
 | 
				
			||||||
 * @param file File path, binary, or readableStream
 | 
					 * @param file File path or readableStream
 | 
				
			||||||
 * @param comment Comment
 | 
					 * @param comment Comment
 | 
				
			||||||
 * @param type File type
 | 
					 * @param type File type
 | 
				
			||||||
 * @param folderId Folder ID
 | 
					 * @param folderId Folder ID
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ const addToGridFS = (name: string, readable: stream.Readable, type: string, meta
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export default (
 | 
					export default (
 | 
				
			||||||
	user: any,
 | 
						user: any,
 | 
				
			||||||
	file: string | Buffer | stream.Readable,
 | 
						file: string | stream.Readable,
 | 
				
			||||||
	name: string = null,
 | 
						name: string = null,
 | 
				
			||||||
	comment: string = null,
 | 
						comment: string = null,
 | 
				
			||||||
	folderId: mongodb.ObjectID = null,
 | 
						folderId: mongodb.ObjectID = null,
 | 
				
			||||||
| 
						 | 
					@ -59,17 +59,6 @@ export default (
 | 
				
			||||||
			res(file);
 | 
								res(file);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (file instanceof Buffer) {
 | 
					 | 
				
			||||||
			tmpFile()
 | 
					 | 
				
			||||||
				.then(path => {
 | 
					 | 
				
			||||||
					fs.writeFile(path, file, (err) => {
 | 
					 | 
				
			||||||
						if (err) rej(err);
 | 
					 | 
				
			||||||
						res(path);
 | 
					 | 
				
			||||||
					});
 | 
					 | 
				
			||||||
				})
 | 
					 | 
				
			||||||
				.catch(rej);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (typeof file === 'object' && typeof file.read === 'function') {
 | 
							if (typeof file === 'object' && typeof file.read === 'function') {
 | 
				
			||||||
			tmpFile()
 | 
								tmpFile()
 | 
				
			||||||
				.then(path => {
 | 
									.then(path => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue