Skip to main content

deleteStaticFile()v4.0.154

Deletes a file from the public directory.
This API is useful for building interactive experiences in the Remotion Studio.

Examples​

Delete 'video.webm'
import React, { useCallback } from "react"; import { deleteStaticFile } from "@remotion/studio"; export const DeleteStaticFileComp: React.FC = () => { const deleteFile = useCallback(async () => { const { existed } = await deleteStaticFile("video.webm"); console.log(`Deleted file (${existed ? "existed" : "did not exist"})`); }, []); return <button onClick={deleteFile}>Delete</button>; };

Rules​

1 This API can only be used while in the Remotion Studio. It throws in a read-only Studio.
2 The file path must be relative to the public directory .
3 It's not allowed to delete a file outside the public directory .
4 To delete a file in a subfolder, use forward slashes / even on Windows.
5 You can, but don't have to wrap the file path in a staticFile() function.

Arguments​

relativePath​

The path of the file to delete, relative to the public directory.

Return value​

A promise that resolves to an object with the following properties:

success​

Always true when the promise resolves.

existed​

Whether the file existed before it was deleted.

Compatibility​

BrowsersEnvironments
Chrome
Firefox
Safari
Editable Studio

See also​