本文整理汇总了TypeScript中fs-extra.createReadStream函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createReadStream函数的具体用法?TypeScript createReadStream怎么用?TypeScript createReadStream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createReadStream函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: addTranslations
public async addTranslations(
file: string,
language: string,
documentPath: string,
options: any
) {
const formData = new FormData()
formData.append('file', fs.createReadStream(file))
formData.append('document_path', documentPath)
formData.append('document_format', this.config.format)
formData.append('language', language)
let url = `${this.apiUrl}/add-translations`
if (!options.write) url = `${url}/peek`
if (options['merge-type']) {
formData.append('merge_type', options['merge-type'])
}
const response = await fetch(url, {
body: formData,
headers: this.authorizationHeader(),
method: 'POST'
})
return this.handleResponse(response, options, OperationName.AddTranslation)
}
开发者ID:mirego,项目名称:accent-cli,代码行数:27,代码来源:document.ts
示例2: callback
database.save(DEFAULT_USER, defaultUser, (err, result) => {
if (err) {
return callback(err);
}
var attachmentData = {
'Content-Type': 'image/' + ext,
name: 'user'
};
var readstream = fse.createReadStream(originalPicture);
var writestream = database.saveAttachment(result, attachmentData, (err, result)=> {
if (err) {
return callback(err);
}
var attachmentData = {
'Content-Type': 'image/' + ext,
name: 'userThumb'
};
var readstream = fse.createReadStream(thumbnailPicture);
var writestream = database.saveAttachment(result, attachmentData, callback);
// stream thumbnail
readstream.pipe(writestream);
});
// stream picture
readstream.pipe(writestream);
});
开发者ID:locator-kn,项目名称:ark-database,代码行数:33,代码来源:setup.ts
示例3: resolve
new Promise<string>((resolve, reject) => {
let data = ''
const stream = fs.createReadStream(file, { encoding: 'utf-8' })
stream.on('data', chunk => (data += chunk))
stream.on('end', () => resolve(data))
stream.on('error', err => reject(err))
})
开发者ID:leslieSie,项目名称:docz,代码行数:8,代码来源:fs.ts
示例4:
return new Promise<void>((resolve, reject) => {
const rs = fs.createReadStream(from);
const ws = fs.createWriteStream(to);
rs.on('error', reject);
ws.on('error', reject);
ws.on('close', resolve);
rs.pipe(ws);
});
开发者ID:headinclouds,项目名称:angular-cli,代码行数:10,代码来源:build.ts
示例5: Promise
.then(() => new Promise((resolve, reject) => {
const rd = fs.createReadStream(from);
rd.on('error', (err: Error) => reject(err));
const wr = fs.createWriteStream(to);
wr.on('error', (err: Error) => reject(err));
wr.on('close', () => resolve());
rd.pipe(wr);
}));
开发者ID:3L4CKD4RK,项目名称:angular-cli,代码行数:10,代码来源:fs.ts
示例6: process
function process(response: express.Response, filePath: string) {
let chapterPages = [] as shared.IApiChapter;
fs.createReadStream(filePath)
.pipe(unzipper.Parse())
.on('close', () => response.send(chapterPages))
.on('entry', (entry: unzipper.Entry) => {
chapterPages.push(entry.path);
entry.autodrain();
});
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:10,代码来源:chapter.ts
示例7: resolve
return await new Promise<Buffer>((resolve, reject) => {
const chunks = new Array<Buffer>()
let total = 0
Fs.createReadStream(path, { start, end })
.on('data', (chunk: Buffer) => {
chunks.push(chunk)
total += chunk.length
})
.on('error', reject)
.on('end', () => resolve(Buffer.concat(chunks, total)))
})
开发者ID:Ahskys,项目名称:desktop,代码行数:12,代码来源:file-system.ts
示例8: test
test('rewrites long complex file', async (t) => {
const beforeStream = fs.createReadStream(
path.join(__dirname, '../../src/test/goldens/paper-button-demo.html'));
beforeStream.setEncoding('utf8');
const expected = await fs.readFile(
path.join(
__dirname, '../../src/test/goldens/paper-button-demo-expected.html'),
'utf8');
const actualStream = beforeStream.pipe(new HTMLRewriter({}));
t.is(await getStream(actualStream), expected);
});
开发者ID:customelements,项目名称:v2,代码行数:12,代码来源:html-rewriter-test.ts
示例9: Promise
return new Promise((resolve, reject) => {
const writeStream = createWriteStream(destPath);
writeStream.on('error', (err: Error) => {
reject(err);
});
writeStream.on('close', () => {
resolve();
});
createReadStream(srcPath).pipe(writeStream);
});
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:13,代码来源:helpers.ts
示例10: process
function process(request: express.Request, response: express.Response, filePath: string) {
fs.createReadStream(filePath)
.pipe(unzipper.Parse())
.on('close', () => {
if (response.headersSent) return;
response.sendStatus(404);
})
.on('entry', (entry: unzipper.Entry) => {
if (entry.path !== request.params.pageName) return entry.autodrain();
response.set('Content-Type', mime.getType(entry.path) || 'application/octet-stream');
return entry.pipe(response);
});
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:13,代码来源:page.ts
注:本文中的fs-extra.createReadStream函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论