Remote files

What is Remote files

In Val, remote files are files which are not stored in your git repository. Instead they are living on Vals remote server. Remote files are always immutable.

Before you you start

To get started with remote files, you need to:

  1. Connect to Val Build

  2. Login using the CLI, by running the command below

Bash
npx -p @valbuild/cli val login

Setting up remote files schemas

To make an image or file a remote image or file, use the .remote() method. If you already have an existing file, you will see a validation error. Use the VS Code extension or the CLI to fix this validation error by uploading the file.

s.image().remote() // or
s.file().remote()

Uploading Remote Files with VS Code Extension

Watch how to upload and manage remote files using the Val VS Code extension. The extension provides a convenient way to upload files directly from your editor. Val works both ways: you can upload files by adding .remote(), and if you remove it, the extension will prompt you to download the files.

Uploading Remote Files with CLI

Watch how to upload and manage remote files using the Val CLI. The CLI is especially useful when you have many files to upload at once. Use npx -p @valbuild/cli val validate --fix to automatically upload all remote files.

NOTE that Val works both ways: you can upload using the VS Code or the CLI if you add the .remote(). If you remove it, you will be prompted to download the files.

If you have a lot of files, we recommend to use the CLI.

Defining content

As stated above, you should not define the remote files yourself, since they have to be uploaded.

Note that it is possible to change the part of the URL that comes after the /p/public/val to whatever you want the filename to be, as long as the file extension is the same.

// Example of a public remote file
// You can change the filename snurrebart to whatever you want
c.remote("https://remote.val.build/file/p/ce803e0/b/v08/v/0.84.1/h/637c/f/c89d27d4be02/p/public/val/snurrebart.png") 

Uploading files

If you are using the VS code plugin, you should be prompted to upload the files directly in the editor. You can also upload all files automatically using the CLI by running the validation command with the --fix option.

npx -p @valbuild/cli val validation --fix