# Upload

## *class* <mark style="color:purple;">Upload</mark>

Uploads are the interface for bringing data into Redivis. They are associated with a particular table, and can be created on any table belonging to an unreleased version of a dataset. Multiple uploads can be added to a table, in which case they are "stacked" together (equivalent to a union join, with mixed schemas supported).

## Constructors

<table data-header-hidden><thead><tr><th width="342">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="../../redivis-python/reference/table/table.upload"><strong><code>table$upload</code></strong></a>(upload_name)</td><td>Construct a reference to an upload based on its name.</td></tr></tbody></table>

## Examples

[See more upload examples ->](https://docs.redivis.com/api/client-libraries/redivis-r/examples/uploading-data)

{% tabs %}
{% tab title="Upload tabular file" %}

```python
table <- dataset$table("table_name")

upload <- table$upload()$create(
    "./data.csv",           # Path to file, data.frame, raw vector, etc
    type="delimited",       # Inferred from file extension if not provided
    remove_on_fail=True,    # Remove the upload if a failure occurs
    wait_for_finish=True,   # Wait for the upload to finish processing
    raise_on_fail=True      # Raise an error on failure
)
```

{% endtab %}

{% tab title="Upload multiple files" %}

```python
dataset <- redivis$user("user_name")$dataset("dataset_name", version="next")
table <- dataset$table("table_name")

dir_path <- "/path/to/data/directory"

for (filename in list.files(dir_path)){
    upload <- table$upload()$create(content=base::file.path(dir_path, filename))
}
```

{% endtab %}
{% endtabs %}

## Attributes

| **`table`**      | A reference to the [Table](https://docs.redivis.com/api/client-libraries/redivis-r/reference/table) instance that constructed this upload.                                                                                          |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`properties`** | A named list containing the [API resource representation of the upload](https://docs.redivis.com/api/resource-definitions/upload#get). This will only be populated after certain methods are called, particularly the `get` method. |

## Methods

<table data-header-hidden><thead><tr><th width="430">Name</th><th>Description</th></tr></thead><tbody><tr><td><a href="upload/uploadusdcreate"><strong><code>upload$create</code></strong></a>(data[, ...])</td><td>Create an upload with the provided data and/or configuration.</td></tr><tr><td><a href="upload/uploadusddelete"><strong><code>upload$delete</code></strong></a>()</td><td>Delete an upload.</td></tr><tr><td><a href="upload/uploadusdexists"><strong><code>upload$exists</code></strong></a>()</td><td>Check whether an upload exists.</td></tr><tr><td><a href="upload/uploadusdget"><strong><code>upload$get</code></strong></a>()</td><td>Fetch an upload and populate <code>upload$properties</code></td></tr><tr><td><a href="upload/uploadusdinsert_rows"><strong><code>upload$insert_rows</code></strong></a>(rows, [, update_schema])</td><td>Insert rows into an upload of type <code>"stream"</code></td></tr><tr><td><a href="upload/uploadusdlist_variables"><strong><code>upload$list_variables</code></strong></a>([max_results])</td><td>List the <a href="variable">variables</a> associated with a given upload.</td></tr><tr><td><a href="upload/uploadusdto_"><strong><code>upload$to_*</code></strong></a>([max_results,  ...])</td><td>Various methods to read data out of an imported (but not yet released) upload. Mirrors the various <a href="table">Table$to_*</a> methods (e.g., <code>upload$to_tibble()</code></td></tr><tr><td><a href="upload/uploadusdvariable"><strong><code>upload$variable</code></strong></a>(name)</td><td>Construct a new <a href="variable">variable instance</a>, scoped to this upload.</td></tr></tbody></table>
