# Download data
<subtitle>Download files from the sandbox to local. </subtitle>

You can use the `files.read()` method to download data from the sandbox.

```python
from ucloud_sandbox import Sandbox

sandbox = Sandbox.create()

# Read files from the sandbox
content = sandbox.files.read('/path/in/sandbox')
# Write the file to the local file system
with open('/local/path', 'w') as file:
  file.write(content)
```

## Download using pre-signed URL

Sometimes, you may want to let users from an unauthorized environment (such as a browser) download files from the sandbox. For this use case, you can use a presigned URL to allow users to download files securely.

You just create the sandbox using the `secure=True` option. A download URL will then be generated with a signature that only allows authorized users to access the file. You can optionally set an expiration time for a URL so that it is only valid for a limited time.

```python
from ucloud_sandbox import Sandbox

# Start the security sandbox (all operations must be authorized by default)
sandbox = Sandbox.create(timeout=12_000, secure=True)

# Create a pre-signed file download URL valid for 10 seconds
# Users can download the file simply by visiting the URL, which also works in the browser
signed_url = sbx.download_url(path="demo.txt", user="user", use_signature_expiration=10_000)
```
