Add uploading to internal cloud storage

Summary:
Design doc: https://docs.google.com/document/d/1HLCFl46RfqG0o1mSt8SWrwf_HMfOCRg_oENioc1rkvQ/edit#

We'll use it in the subsequent diff to automatically upload a universal export

Reviewed By: passy

Differential Revision: D40585810

fbshipit-source-id: 5b409d716c2ead040865130d379d4f593cb68483
This commit is contained in:
Andrey Goncharov
2022-10-25 05:31:48 -07:00
committed by Facebook GitHub Bot
parent 5d921966fb
commit 970c03d942
3 changed files with 26 additions and 0 deletions

View File

@@ -325,6 +325,7 @@ export type FlipperServerCommands = {
'intern-upload-scribe-logs': (
messages: {category: string; message: string}[],
) => Promise<void>;
'intern-cloud-upload': (path: string) => Promise<string>;
shutdown: () => Promise<void>;
'is-logged-in': () => Promise<boolean>;
'environment-info': () => Promise<EnvironmentInfo>;

View File

@@ -55,6 +55,7 @@ import {assertNotNull} from './comms/Utilities';
import {mkdirp} from 'fs-extra';
import {flipperDataFolder, flipperSettingsFolder} from './utils/paths';
import {DebuggableDevice} from './devices/DebuggableDevice';
import {jfUpload} from './fb-stubs/jf';
const {access, copyFile, mkdir, unlink, stat, readlink, readFile, writeFile} =
promises;
@@ -535,6 +536,13 @@ export class FlipperServerImpl implements FlipperServer {
return internGraphGETAPIRequest(endpoint, params, options, token);
},
'intern-upload-scribe-logs': sendScribeLogs,
'intern-cloud-upload': async (path) => {
const uploadRes = await jfUpload(path);
if (!uploadRes) {
throw new Error('Upload failed');
}
return uploadRes;
},
shutdown: async () => {
process.exit(0);
},

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
/**
* Upload a file at path to a temporary cloud storage
*
* @returns Download URL
*/
export const jfUpload = async (_path: string): Promise<string> => {
throw new Error('jf upload is not implemented');
};