const stream = fs.createReadStream('<filepath>/example.pdf', {bufferSize: 64 * 1024})
stream.pipe(res); let had_error = false;
stream.on('error', function(err){
had_error = true;
});
stream.on('close', function(){
if (!had_error) fs.unlink('<filepath>/example.pdf');
});

createReadStream().pipe() Callback的更多相关文章

  1. [转]新浪云存储SCS Node.js使用指南

    转载自:https://github.com/SinaCloudStorage/scs-sdk-js scs-sdk-js 新浪云存储(SCS) SDK for Node.js Installatio ...

  2. fs.createReadStream(filepath).pipe(response);这句是什么意思?

    'use strict'; var fs = require('fs'), url = require('url'), path = require('path'), http = require(' ...

  3. learning nodejs 1 - stream.pipe

    a simple http server using inner http module. var http = require('http'); var fs = require('fs'); // ...

  4. CVE-2017-7494 Linux Samba named pipe file Open Vul Lead to DLL Execution

    catalogue . 漏洞复现 . 漏洞代码原理分析 . 漏洞利用前提 . 临时缓解 && 修复手段 1. 漏洞复现 . SMB登录上去 . 枚举共享目录,得到共享目录/文件列表,匿 ...

  5. Linux中的pipe(管道)与named pipe(FIFO 命名管道)

    catalogue . pipe匿名管道 . named pipe(FIFO)有名管道 1. pipe匿名管道 管道是Linux中很重要的一种通信方式,是把一个程序的输出直接连接到另一个程序的输入,常 ...

  6. 20.pipe

    pipe相当于angular1里面的filter 做一些格式转换啊,或者从一个数组里面选取一个元素等等 只要你愿意可以定义很复杂的内容‘’ 我们先看看 angular2 里面自带的一些pipe 我们去 ...

  7. gulp中pipe的作用和来源

    gulp的pipe方法是来自nodejs stream API的,并不是gulp本身源码所定义的. 一.pipe方法的作用 pipe跟他字面意思一样只是一个管道 例如我有一堆文件 var s = gu ...

  8. nodejs pipe实现大文件拷贝

    原文: http://nqdeng.github.io/7-days-nodejs/ --------------------------------------------------------- ...

  9. 如何写一个能在gulp build pipe中任意更改src内容的函数

    gulp在前端自动化构建中非常好用,有非常丰富的可以直接拿来使用的plugin,完成我们日常构建工作. 但是万事没有十全十美能够完全满足自己的需求,这时我们就要自己动手写一个小的函数,用于在gulp ...

随机推荐

  1. shell选项和参数

  2. go语言从例子开始之Example15.闭包

    Go 支持通过 闭包来使用 匿名函数.匿名函数在你想定义一个不需要命名的内联函数时是很实用的. 闭包简单理解,函数反回值是一个函数 Example: package main import " ...

  3. centos系统jdk安装

    下载Oracle官网的jdk来安装 不使用openjdk 最新的官网地址: https://www.oracle.com/technetwork/java/javase/downloads/jdk8- ...

  4. 人脸识别课件需要安装的python模块

    Python3.6安装face_recognition人脸识别库 https://www.jianshu.com/p/8296f2aac1aa

  5. Python技能树

    本博客Python内容的索引,以后就照着它写了.

  6. 1.MVC的初步了解

    1.MVC简单介绍 1)原理(如图)如果想更加深入了解原理,可以访问此地址(https://www.cnblogs.com/uicodeintoworld/p/8950877.html) 理解:客户端 ...

  7. 手写Spring事务框架

    Spring事务基于AOP环绕通知和异常通知 编程事务 声明事务 Spring事务底层使用编程事务+AOP进行包装的   = 声明事务 AOP应用场景:  事务 权限 参数验证 什么是AOP技术 AO ...

  8. 理解Java主函数中的"String[] args"

    public class Understand_String_args { public static void main(String[] args) { System.out.printf(&qu ...

  9. cookieUtils.js

    cookieUtils.js export default { data () { return { } }, created () { }, methods: { arrayContain (arr ...

  10. paper 136:ARM ADS集成开发环境的使用(新版)

    [转载]:http://blog.csdn.net/yhmhappy2006/article/details/1673203 ARM ADS集成开发环境的使用 在这里,将介绍ARM开发软件ADS(AR ...