Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

feat: add [marimo.server.disable_file_downloads] (#7844)

Anirudh Dagarfc3d0fdd2bfc
diff --git a/frontend/src/components/editor/file-tree/file-explorer.tsx b/frontend/src/components/editor/file-tree/file-explorer.tsx
index c1d51d9ccf..073604b4ac 100644
--- a/frontend/src/components/editor/file-tree/file-explorer.tsx
+++ b/frontend/src/components/editor/file-tree/file-explorer.tsx
@@ -1,6 +1,6 @@
/* Copyright 2026 Marimo. All rights reserved. */
-import { useAtom } from "jotai";
+import { useAtom, useAtomValue } from "jotai";
import { atomWithStorage } from "jotai/utils";
import {
ArrowLeftIcon,
@@ -47,6 +47,7 @@ import { Tooltip } from "@/components/ui/tooltip";
import { toast } from "@/components/ui/use-toast";
import { useCellActions } from "@/core/cells/cells";
import { useLastFocusedCellId } from "@/core/cells/focus";
+import { disableFileDownloadsAtom } from "@/core/config/config";
import { useRequestClient } from "@/core/network/requests";
import type { FileInfo } from "@/core/network/types";
import { isWasm } from "@/core/wasm/utils";
@@ -396,6 +397,7 @@ const Edit = ({ node }: { node: NodeApi<FileInfo> }) => {
const Node = ({ node, style, dragHandle }: NodeRendererProps<FileInfo>) => {
const { openFile, sendCreateFileOrFolder, sendFileDetails } =
useRequestClient();
+ const disableFileDownloads = useAtomValue(disableFileDownloadsAtom);
const fileType: FileType = node.data.isDirectory
? "directory"
@@ -611,7 +613,7 @@ const Node = ({ node, style, dragHandle }: NodeRendererProps<FileInfo>) => {
</>
)}
<DropdownMenuSeparator />
- {!node.data.isDirectory && (
+ {!node.data.isDirectory && !disableFileDownloads && (
<>
<DropdownMenuItem
onSelect={async () => {
diff --git a/frontend/src/components/editor/file-tree/file-viewer.tsx b/frontend/src/components/editor/file-tree/file-viewer.tsx
index 47b2da9d50..9f1c856e11 100644
--- a/frontend/src/components/editor/file-tree/file-viewer.tsx
+++ b/frontend/src/components/editor/file-tree/file-viewer.tsx
@@ -15,7 +15,7 @@ import { Suspense, useEffect, useRef, useState } from "react";
import { renderShortcut } from "@/components/shortcuts/renderShortcut";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Tooltip } from "@/components/ui/tooltip";
-import { hotkeysAtom } from "@/core/config/config";
+import { disableFileDownloadsAtom, hotkeysAtom } from "@/core/config/config";
import { useRequestClient } from "@/core/network/requests";
import type { FileInfo } from "@/core/network/types";
import { filenameAtom } from "@/core/saving/file-state";
@@ -49,6 +49,7 @@ export const FileViewer: React.FC<Props> = ({ file, onOpenNotebook }) => {
const { theme } = useTheme();
const { sendFileDetails, sendUpdateFile } = useRequestClient();
const hotkeys = useAtomValue(hotkeysAtom);
+ const disableFileDownloads = useAtomValue(disableFileDownloadsAtom);
const currentNotebookFilename = useAtomValue(filenameAtom);
// undefined value means not modified yet
const [internalValue, setInternalValue] = useState<string>("");
@@ -152,11 +153,13 @@ export const FileViewer: React.FC<Props> = ({ file, onOpenNotebook }) => {
</Button>
</Tooltip>
)}
- <Tooltip content="Download">
- <Button size="small" onClick={handleDownload}>
- <DownloadIcon />
- </Button>
- </Tooltip>
+ {!disableFileDownloads && (
+ <Tooltip content="Download">
+ <Button size="small" onClick={handleDownload}>
+ <DownloadIcon />
+ </Button>
+ </Tooltip>
+ )}
{!isMedia(mimeType) && (
<>
<Tooltip content="Copy contents to clipboard">
diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts
index 1383086081..956d627c85 100644
--- a/frontend/src/core/config/config-schema.ts
+++ b/frontend/src/core/config/config-schema.ts
@@ -190,7 +190,11 @@ export const UserConfigSchema = z
})
// Pass through so that we don't remove any extra keys that the user has added.
.prefault(() => ({})),
- server: z.looseObject({}).prefault(() => ({})),
+ server: z
+ .looseObject({
+ disable_file_downloads: z.boolean().optional(),
+ })
+ .prefault(() => ({})),
diagnostics: z
.looseObject({
enabled: z.boolean().optional(),
diff --git a/frontend/src/core/config/config.ts b/frontend/src/core/config/config.ts
index 61a585755a..5d96e697c5 100644
--- a/frontend/src/core/config/config.ts
+++ b/frontend/src/core/config/config.ts
@@ -125,3 +125,7 @@ export const snippetsEnabledAtom = atom<boolean>((get) => {
const includeDefaultSnippets = config.snippets?.include_default_snippets;
return customPaths.length > 0 || includeDefaultSnippets === true;
});
+
+export const disableFileDownloadsAtom = atom<boolean>((get) => {
+ return get(resolvedMarimoConfigAtom).server?.disable_file_downloads ?? false;
+});
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index c87f4fae46..63032dd99e 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -235,10 +235,13 @@ class ServerConfig(TypedDict):
with Python's webbrowser module (eg, `"firefox"` or `"chrome"`)
- `follow_symlink`: if true, the server will follow symlinks it finds
inside its static assets directory.
+ - `disable_file_downloads`: if true, the file download button will be
+ hidden in the file explorer.
"""
browser: Union[Literal["default"], str]
follow_symlink: bool
+ disable_file_downloads: NotRequired[bool]
@dataclass
diff --git a/packages/openapi/api.yaml b/packages/openapi/api.yaml
index dff3dfc95c..4bb8b1eb15 100644
--- a/packages/openapi/api.yaml
+++ b/packages/openapi/api.yaml
@@ -3609,13 +3609,16 @@ components:
\ the web browser to use. `\"default\"` or a browser registered\n with\
\ Python's webbrowser module (eg, `\"firefox\"` or `\"chrome\"`)\n - `follow_symlink`:\
\ if true, the server will follow symlinks it finds\n inside its static\
- \ assets directory."
+ \ assets directory.\n - `disable_file_downloads`: if true, the file download\
+ \ button will be\n hidden in the file explorer."
properties:
browser:
anyOf:
- enum:
- default
- type: string
+ disable_file_downloads:
+ type: boolean
follow_symlink:
type: boolean
required:
diff --git a/packages/openapi/src/api.ts b/packages/openapi/src/api.ts
index 466921b908..08397fe7e3 100644
--- a/packages/openapi/src/api.ts
+++ b/packages/openapi/src/api.ts
@@ -4997,9 +4997,12 @@ export interface components {
* with Python's webbrowser module (eg, `"firefox"` or `"chrome"`)
* - `follow_symlink`: if true, the server will follow symlinks it finds
* inside its static assets directory.
+ * - `disable_file_downloads`: if true, the file download button will be
+ * hidden in the file explorer.
*/
ServerConfig: {
browser: "default" | string;
+ disable_file_downloads?: boolean;
follow_symlink: boolean;
};
/** SetupRootError */