π₯ Make videos programmatically with React
can now download files rendered on cloudrun, through cli
Matt McGillivray2f4156f9de42
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex d3a69f555a..5fbe34904b 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -5,6 +5,7 @@"source.fixAll": true},"cSpell.words": [+ "gsutil","rmall"]}diff --git a/packages/cloudrun/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/gcpInstaller/gcpInstaller.tarindex a78893aed3..947a9d9a7d 100644Binary files a/packages/cloudrun/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/gcpInstaller/gcpInstaller.tar differdiff --git a/packages/cloudrun/src/api/download-file.ts b/packages/cloudrun/src/api/download-file.tsnew file mode 100644index 0000000000..3d5efcd7fd--- /dev/null+++ b/packages/cloudrun/src/api/download-file.ts@@ -0,0 +1,29 @@+import fs from 'fs';+import {getCloudStorageClient} from './helpers/get-cloud-storage-client';++export const downloadFile = async ({+ bucketName,+ gsutilURI,+ downloadName,+}: {+ bucketName: string;+ gsutilURI: string;+ downloadName: string;+}) => {+ const cloudStorageClient = getCloudStorageClient();++ const fileName = gsutilURI.replace(`gs://${bucketName}/`, '');++ // check if out folder exists, if not, create it+ if (!fs.existsSync('out')) {+ fs.mkdirSync('out');+ }++ const destination = `out/${downloadName}`;++ await cloudStorageClient.bucket(bucketName).file(fileName).download({+ destination,+ });++ return destination;+};diff --git a/packages/cloudrun/src/cli/commands/render/renderMedia.ts b/packages/cloudrun/src/cli/commands/render/renderMedia.tsindex 80a2cb0925..ae280b930a 100644--- a/packages/cloudrun/src/cli/commands/render/renderMedia.ts+++ b/packages/cloudrun/src/cli/commands/render/renderMedia.ts@@ -3,6 +3,7 @@ import type {RenderMediaOnCloudrunOutput} from '../../../api/render-media-on-cloimport {renderMediaOnCloudrun} from '../../../api/render-media-on-cloudrun';import type {CloudrunCodec} from '../../../shared/validate-gcp-codec';// import {validateMaxRetries} from '../../../shared/validate-retries';+import {downloadFile} from '../../../api/download-file';import {Log} from '../../log';import {renderArgsCheck} from './helpers/renderArgsCheck';@@ -21,6 +22,7 @@ export const renderMediaSubcommand = async (codecReason,inputProps,outputBucket,+ downloadName,privacy,authenticatedRequest,} = await renderArgsCheck(RENDER_MEDIA_SUBCOMMAND, args, remotionRoot);@@ -97,7 +99,7 @@ Sending request to Cloud Run:Log.info(CliInternals.chalk.blueBright(`-π€ Rendered on Cloud Run! π€+π€ Rendered media on Cloud Run! π€Public URL = ${success.publicUrl}Cloud Storage Uri = ${success.cloudStorageUri}@@ -109,4 +111,19 @@ Sending request to Cloud Run:`.trim()));++ if (downloadName) {+ Log.info('');+ Log.info('downloading file...');++ const destination = await downloadFile({+ bucketName: success.bucketName,+ gsutilURI: success.cloudStorageUri,+ downloadName,+ });++ Log.info(+ CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`)+ );+ }};diff --git a/packages/cloudrun/src/cli/commands/render/renderStill.ts b/packages/cloudrun/src/cli/commands/render/renderStill.tsindex 11011a5630..55edb9e113 100644--- a/packages/cloudrun/src/cli/commands/render/renderStill.ts+++ b/packages/cloudrun/src/cli/commands/render/renderStill.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import {downloadFile} from '../../../api/download-file';import type {RenderStillOnCloudrunOutput} from '../../../api/render-still-on-cloudrun';import {renderStillOnCloudrun} from '../../../api/render-still-on-cloudrun';import {Log} from '../../log';@@ -80,7 +81,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}Log.info(CliInternals.chalk.blueBright(`-π€ Rendered on Cloud Run! π€+π€ Rendered still on Cloud Run! π€Public URL = ${success.publicUrl}Cloud Storage Uri = ${success.cloudStorageUri}@@ -91,4 +92,19 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}`.trim()));++ if (downloadName) {+ Log.info('');+ Log.info('downloading file...');++ const destination = await downloadFile({+ bucketName: success.bucketName,+ gsutilURI: success.cloudStorageUri,+ downloadName,+ });++ Log.info(+ CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`)+ );+ }};