> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload.md).

# 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

| Method                                                                                                                                  | Description                                                                                                                 |
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| [**`Table.upload`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table/table.upload.md)(\[name])                 | Construct a reference to an upload. `name` is optional, and will be inferred from the uploaded file's name if not provided. |
| [**`Table.listUploads`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table/table.listuploads.md)(\[maxResults]) | List the uploads on a table.                                                                                                |

## Examples

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

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

```javascript
const dataset = redivis.user('user_name').dataset('dataset_name', { version: 'next' });
const table = dataset.table('table_name');

// In Node.js, upload a file from disk
await table.upload().create('./data.csv');

// In the browser, upload a File (e.g., from an <input type="file">)
await table.upload().create(fileInput.files[0], {
  onProgress: ({ bytesUploaded, totalBytes }) => console.log(bytesUploaded / totalBytes),
});
```

{% endtab %}

{% tab title="Upload rows" %}

```javascript
const table = redivis.user('user_name').dataset('dataset_name', { version: 'next' }).table('table_name');

// Arrays of row objects (and arrow Tables) are uploaded as newline-delimited JSON
await table.upload('rows').create([
  { id: 1, name: 'a' },
  { id: 2, name: 'b' },
]);
```

{% endtab %}

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

```javascript
import { readdir } from 'node:fs/promises';
import path from 'node:path';

const table = redivis.user('user_name').dataset('dataset_name', { version: 'next' }).table('table_name');
const directory = '/path/to/data/directory';

for (const fileName of await readdir(directory)) {
  await table.upload().create(path.join(directory, fileName));
}
```

{% endtab %}
{% endtabs %}

## Attributes

| Name             | Description                                                                                                                                                                                                                     |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`**       | The upload's name.                                                                                                                                                                                                              |
| **`table`**      | A reference to the [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md) that the upload belongs to.                                                                                             |
| **`properties`** | An object containing the [API resource representation of the upload](https://docs.redivis.com/api/resource-definitions/upload.md). This will only be populated after certain methods are called, particularly the `get` method. |

## Methods

| Method                                                                                                                                         | Description                                                                                                                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**`Upload.create`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.create.md)(\[content, options])         | Create an upload with the provided data and/or configuration.                                                                                                                                                                                 |
| [**`Upload.delete`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.delete.md)()                            | Delete the upload.                                                                                                                                                                                                                            |
| [**`Upload.download`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table/table.download.md)(\[path, options])          | Export the upload in a particular format and download it to disk (Node.js only).                                                                                                                                                              |
| [**`Upload.exists`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.exists.md)()                            | Check whether the upload exists.                                                                                                                                                                                                              |
| [**`Upload.get`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.get.md)()                                  | Fetch the upload, populating `upload.properties`.                                                                                                                                                                                             |
| [**`Upload.insertRows`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.insertrows.md)(rows)                | Insert rows into an upload of type `stream`.                                                                                                                                                                                                  |
| [**`Upload.listVariables`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.listvariables.md)(\[maxResults]) | List the [variables](https://docs.redivis.com/api/client-libraries/redivis-js/reference/variable.md) of the upload.                                                                                                                           |
| [**`Upload.to*`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.to.md)(\[maxResults, options])             | Various methods to read data out of an imported (but not yet released) upload. Mirrors the various [`Table.to*`](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md#methods) methods (e.g., `upload.toRowsArray()`). |
| [**`Upload.variable`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload/upload.variable.md)(name)                    | Return a [Variable](https://docs.redivis.com/api/client-libraries/redivis-js/reference/variable.md) within this upload.                                                                                                                       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-js/reference/upload.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
