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

# Camel.loaders.base io

<a id="camel.loaders.base_io" />

<a id="camel.loaders.base_io.create_file" />

## create\_file

```python theme={"system"}
def create_file(file: BytesIO, filename: str):
```

Reads an uploaded file and returns a File object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the file.
* **filename** (str): The name of the file.

**Returns:**

File: A File object.

<a id="camel.loaders.base_io.create_file_from_raw_bytes" />

## create\_file\_from\_raw\_bytes

```python theme={"system"}
def create_file_from_raw_bytes(raw_bytes: bytes, filename: str):
```

Reads raw bytes and returns a File object.

**Parameters:**

* **raw\_bytes** (bytes): The raw bytes content of the file.
* **filename** (str): The name of the file.

**Returns:**

File: A File object.

<a id="camel.loaders.base_io.File" />

## File

```python theme={"system"}
class File(ABC):
```

Represents an uploaded file comprised of Documents.

**Parameters:**

* **name** (str): The name of the file.
* **file\_id** (str): The unique identifier of the file.
* **metadata** (Dict\[str, Any], optional): Additional metadata associated with the file. Defaults to None.
* **docs** (List\[Dict\[str, Any]], optional): A list of documents contained within the file. Defaults to None.
* **raw\_bytes** (bytes, optional): The raw bytes content of the file. Defaults to b"".

<a id="camel.loaders.base_io.File.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    name: str,
    file_id: str,
    metadata: Optional[Dict[str, Any]] = None,
    docs: Optional[List[Dict[str, Any]]] = None,
    raw_bytes: bytes = b''
):
```

<a id="camel.loaders.base_io.File.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a File object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the file.
* **filename** (str): The name of the file.

**Returns:**

File: A File object.

<a id="camel.loaders.base_io.File.from_raw_bytes" />

### from\_raw\_bytes

```python theme={"system"}
def from_raw_bytes(cls, raw_bytes: bytes, filename: str):
```

Creates a File object from raw bytes.

**Parameters:**

* **raw\_bytes** (bytes): The raw bytes content of the file.
* **filename** (str): The name of the file.

**Returns:**

File: A File object.

<a id="camel.loaders.base_io.File.__repr__" />

### **repr**

```python theme={"system"}
def __repr__(self):
```

<a id="camel.loaders.base_io.File.__str__" />

### **str**

```python theme={"system"}
def __str__(self):
```

<a id="camel.loaders.base_io.File.copy" />

### copy

```python theme={"system"}
def copy(self):
```

Create a deep copy of this File

<a id="camel.loaders.base_io.strip_consecutive_newlines" />

## strip\_consecutive\_newlines

```python theme={"system"}
def strip_consecutive_newlines(text: str):
```

Strips consecutive newlines from a string.

**Parameters:**

* **text** (str): The string to strip.

**Returns:**

str: The string with consecutive newlines stripped.

<a id="camel.loaders.base_io.DocxFile" />

## DocxFile

```python theme={"system"}
class DocxFile(File):
```

<a id="camel.loaders.base_io.DocxFile.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a DocxFile object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the docx file.
* **filename** (str): The name of the file.

**Returns:**

DocxFile: A DocxFile object.

<a id="camel.loaders.base_io.PdfFile" />

## PdfFile

```python theme={"system"}
class PdfFile(File):
```

<a id="camel.loaders.base_io.PdfFile.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a PdfFile object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the pdf file.
* **filename** (str): The name of the file.

**Returns:**

PdfFile: A PdfFile object.

<a id="camel.loaders.base_io.TxtFile" />

## TxtFile

```python theme={"system"}
class TxtFile(File):
```

<a id="camel.loaders.base_io.TxtFile.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a TxtFile object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the txt file.
* **filename** (str): The name of the file.

**Returns:**

TxtFile: A TxtFile object.

<a id="camel.loaders.base_io.JsonFile" />

## JsonFile

```python theme={"system"}
class JsonFile(File):
```

<a id="camel.loaders.base_io.JsonFile.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a JsonFile object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the json file.
* **filename** (str): The name of the file.

**Returns:**

JsonFile: A JsonFile object.

<a id="camel.loaders.base_io.HtmlFile" />

## HtmlFile

```python theme={"system"}
class HtmlFile(File):
```

<a id="camel.loaders.base_io.HtmlFile.from_bytes" />

### from\_bytes

```python theme={"system"}
def from_bytes(cls, file: BytesIO, filename: str):
```

Creates a HtmlFile object from a BytesIO object.

**Parameters:**

* **file** (BytesIO): A BytesIO object representing the contents of the html file.
* **filename** (str): The name of the file.

**Returns:**

HtmlFile: A HtmlFile object.
