# 4.Retrieve and Download Files

### 4.1 List files in a bucket

Get a list of file information from one of your buckets

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

for i in bucket_client.list_files("<BUCKET_NAME>", '<PREFIX>', "<LIMIT>", '<OFFSET>'):
    print(i.to_json())
```

### 4.2 Get file information

Get the file information of a file in one of your buckets

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

print(bucket_client.get_file("<BUCKET_NAME>", "<OBJECT_NAME>").to_json())
```

**Parameters**

* **bucket\_name**: The name of the bucket
* **object\_name:** The object name of the file

### 4.3 Download a file

Downloads the file (located using `bucket_name`/`object_name` from IPFS and writes it to `local_filename`

```python
from swan_mcs import APIClient, BucketAPI
mcs_api = APIClient("<API_KEY>")
bucket_client = BucketAPI(mcs_api)

bucket_client.download_file("<BUCKET_NAME>", "<OBJECT_NAME>", "<LOCAL_FILENAME>")
```

**Parameters**

* **bucket\_name**: The name of the bucket
* **object\_name:** The object name to download
* **local\_filename:** The download destination and filename


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swanchain.io/bulders/app-developer/store-and-retrieve-a-file-with-swan-storage/4.retrieve-and-download-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
