[英]How do I use “stream.pipe(fs.createWriteStream())”
How do I use stream.pipe? 如何使用stream.pipe?
I'm running a function that outputs: 我正在运行一个输出的函数:
const fs = require('fs');
const screenshot = require('screenshot-stream');
const stream = screenshot('http://google.com', '1024x768');
stream.pipe(fs.createWriteStream('picture.png'));
My next step is taking that picture (picture.png) and assigning it here: 我的下一步是拍摄照片(picture.png)并在此处分配:
var content = fs.readFileSync('/path/to/img')
In other words, what is the path to the image so I can upload it? 换句话说,要上传图片的路径是什么?
Lets say, Your project directory name is "PROJECT", And you executed this file from the root directory of your project, Then the PICTURE.png file will be created in the root directory. 假设,您的项目目录名称为“ PROJECT”,并且您从项目的根目录执行了此文件,然后将在根目录中创建PICTURE.png文件。
And the path to that file'll be __dirname + "/PICTURE.png"
if you are still in the root directory of your project. 如果您仍在项目的根目录中,则该文件的路径将为
__dirname + "/PICTURE.png"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.