How to use the @google-cloud/storage.File function in @google-cloud/storage

To help you get started, we’ve selected a few @google-cloud/storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github project-slippi / slippi-desktop-app / app / main.dev.js View on Github external
case "slippi:":
    const tmpDir = os.tmpdir();
    const destination = path.join(tmpDir, 'replay.slp');
    const replayPath = myUrl.searchParams.get('path');

    // The following path generation will not work on dev
    // __static didn't exist and __dirname didn't work. /shrug
    const appPath = app.getAppPath();
    const keyPath = path.join(appPath, "../app.asar.unpacked/static/storage-reader.json");
    log.info(`Keypath: ${keyPath}`);
    const storage = new Storage({
      projectId: 'slippi',
      keyFilename: keyPath,
    });
    const bucket = storage.bucket('slippi.appspot.com');
    const file = new File(bucket, replayPath);

    log.info(`Downloading file ${replayPath} to ${destination}`);

    // Dowload file
    await file.download({ destination: destination });

    log.info(`Finished download`);

    // Wait until mainWindow exists so that we can send an IPC to play.
    // We are willing to wait for a few seconds before timing out
    await waitForMainWindow();
    mainWindow.webContents.send("play-replay", path.join(tmpDir, 'replay.slp'));


    break;
  case "file:":

@google-cloud/storage

Cloud Storage Client Library for Node.js

Apache-2.0
Latest version published 3 days ago

Package Health Score

91 / 100
Full package analysis