Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions koyeb/sandbox/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Union
import asyncio

from .executor_client import SandboxClient
from .utils import (
Expand Down Expand Up @@ -572,7 +573,6 @@ async def is_dir(self, path: str) -> bool:
"""Check if path is a directory asynchronously"""
pass

@async_wrapper("upload_file")
async def upload_file(
self, local_path: str, remote_path: str, encoding: str = "utf-8"
) -> None:
Expand All @@ -584,7 +584,15 @@ async def upload_file(
remote_path: Destination path in the sandbox
encoding: File encoding (default: "utf-8"). Use "base64" for binary files.
"""
pass
if not os.path.exists(local_path):
raise SandboxFileNotFoundError(f"Local file not found: {local_path}")

def _read():
with open(local_path, "rb") as f:
return f.read()

content_bytes = await asyncio.to_thread(_read)
await self.write_file(remote_path, content_bytes, encoding=encoding)

@async_wrapper("download_file")
async def download_file(
Expand Down