🎥 Make videos programmatically with React
error if serve url is gcp storage and doesn't exist
Matt McGillivray224e6dc2d260
diff --git a/packages/cloudrun/src/shared/validate-serveurl.ts b/packages/cloudrun/src/shared/validate-serveurl.tsindex 61132a60fd..b609ea24d6 100644--- a/packages/cloudrun/src/shared/validate-serveurl.ts+++ b/packages/cloudrun/src/shared/validate-serveurl.ts@@ -1,4 +1,6 @@-export const validateServeUrl = (serveUrl: unknown) => {+import {getCloudStorageClient} from '../api/helpers/get-cloud-storage-client';++export const validateServeUrl = async (serveUrl: unknown) => {if (typeof serveUrl !== 'string') {throw new TypeError(`"serveURL" parameter must be a string, but is ${JSON.stringify(@@ -6,4 +8,30 @@ export const validateServeUrl = (serveUrl: unknown) => {)}`);}++ // if GCP Storage URL, validate that file exists+ if (serveUrl.startsWith('https://storage.googleapis.com')) {+ const cloudStorageClient = getCloudStorageClient();++ const bucketName = serveUrl.split('/')[3];+ const fileName = serveUrl.split('/').slice(4).join('/');+ const siteName = serveUrl.split('/')[5];++ const [exists] = await cloudStorageClient+ .bucket(bucketName)+ .file(fileName)+ .exists();++ if (!exists) {+ throw new Error(+ 'serveURL ERROR. File "' ++ fileName ++ '" not found in bucket "' ++ bucketName ++ '". Is your site name correct - "' ++ siteName ++ '"?'+ );+ }+ }};