Add download file API

Summary: Changelog: Expose "downloadFile" API to Flipper plugins. Allow them to download files form the web to Flipper Server.

Reviewed By: mweststrate

Differential Revision: D32950685

fbshipit-source-id: 7b7f666e165ff7bf209230cdc96078272ede3616
This commit is contained in:
Andrey Goncharov
2021-12-10 06:34:37 -08:00
committed by Facebook GitHub Bot
parent 4cb80a452f
commit 92f0ed67f4
12 changed files with 271 additions and 10 deletions

View File

@@ -45,6 +45,7 @@ import {
} from './fb-stubs/internRequests';
import {commandNodeApiExec} from './commands/NodeApiExec';
import {access, copyFile, mkdir, unlink} from 'fs/promises';
import {commandDownloadFileStartFactory} from './commands/DownloadFile';
export const SERVICE_FLIPPER = 'flipper.oAuthToken';
@@ -228,6 +229,11 @@ export class FlipperServerImpl implements FlipperServer {
'node-api-fs-unlink': unlink,
'node-api-fs-mkdir': mkdir,
'node-api-fs-copyFile': copyFile,
// TODO: Unit tests
// TODO: Do we need API to cancel an active download?
'download-file-start': commandDownloadFileStartFactory(
this.emit.bind(this),
),
'get-config': async () => this.config,
'get-changelog': getChangelog,
'device-list': async () => {