deleteStaticFile()v4.0.154
从 public 目录 删除一个文件。
此 API 对于在 Remotion Studio 中构建交互式体验非常有用。
🌐 Deletes a file from the public directory.
This API is useful for building interactive experiences in the Remotion Studio.
示例
🌐 Examples
Delete 'video.webm'importReact , {useCallback } from "react"; import {deleteStaticFile } from "@remotion/studio"; export constDeleteStaticFileComp :React .FC = () => { constdeleteFile =useCallback (async () => { const {existed } = awaitdeleteStaticFile ("video.webm");console .log (`Deleted file (${existed ? "existed" : "did not exist"})`); }, []); return <button onClick ={deleteFile }>Delete</button >; };
规则
🌐 Rules
此 API 仅可在 Remotion Studio 中使用。文件路径必须相对于
public目录
。
不允许删除
public目录之外的文件
。4
要删除子文件夹中的文件,即使在 Windows 上,也要使用正斜杠
/。
5
你可以,也可以不将文件路径封装在
staticFile()
函数中。
另请参阅
🌐 See also