> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ファイル操作

> CoreWeave サンドボックスインスタンスとの間でファイルをアップロードおよびダウンロードするためのチュートリアル

```python theme={"system"}
# 書き込み (content は bytes でなければなりません)
sandbox.write_file("/tmp/hello.txt", b"Hello!").result()

# 読み取り (bytes を返します)
content = sandbox.read_file("/tmp/hello.txt").result()
print(content.decode())
```

`exec()` と同様に、ファイル操作は `OperationRef` を即座に返し、完了を待ちません。データが必要な場合は `.result()` を呼び出してください。これにより、複数の操作を同時に開始し、一緒に待つことができます：

```python theme={"system"}
refs = [sandbox.write_file(f"/tmp/{i}.txt", b"data") for i in range(5)]
for ref in refs:
    ref.result()
```

並列アップロードおよびダウンロードのパターンと S3 マウントについては、[ファイル操作ガイド](/ja/products/sandboxes/client/guides/file-operations) を参照してください。
