當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.createReadStream函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。