# nextcloud-chunk-file-upload

> Nextcloud chunk file upload client

Latest version **1.4.0** (published 2026-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install nextcloud-chunk-file-upload
pnpm add nextcloud-chunk-file-upload
yarn add nextcloud-chunk-file-upload
bun add nextcloud-chunk-file-upload
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-03-30 |
| First published | 2020-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Andreas Rutz <andreas.rutz@posteo.de> |
| Maintainers | shiftpi |
| Keywords | nextcloud, webdav, client, upload, chunk |

## Links

- npm: https://www.npmjs.com/package/nextcloud-chunk-file-upload
- Repository: https://github.com/shiftpi/nextcloud-chunk-file-upload
- Issues: https://github.com/shiftpi/nextcloud-chunk-file-upload/issues
- npm.io page: https://npm.io/package/nextcloud-chunk-file-upload

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.14.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2026-03-30
- 1.3.3 — 2025-10-03
- 1.3.2 — 2025-10-03
- 1.3.1 — 2024-08-14
- 1.3.0 — 2024-07-21
- 1.2.5 — 2024-03-03
- 1.2.4 — 2024-01-20
- 1.2.3 — 2023-10-23
- 1.2.2 — 2023-10-06
- 1.2.1 — 2023-10-06
- 1.2.0 — 2023-07-10
- 1.1.1 — 2023-02-21
- 1.1.0 — 2022-08-18
- 1.0.8 — 2022-04-07
- 1.0.7 — 2022-02-15
- … 7 more at https://npm.io/package/nextcloud-chunk-file-upload/versions

## README

# Nextcloud Chunk File Upload

Upload files to Nextcloud using chunks

Nextcloud offers a chunked upload library, which makes your life a lot easier, if you want to upload large files to
your Nextcloud instance over a bad network.

Use this library if you want to build some sort of upload client in node.js and do that with the joy of Promises 🙌.

## Installation

This package is published on NPM so you can simply type:

```
npm install --save nextcloud-chunk-file-upload
```

or

```
yarn add nextcloud-chunk-file-upload
```

## Usage

### Upload

The core part of this library is a class called `Upload`, which takes care of server parameters, like the server's
address and your credentials. If you want to start an upload, call ``uploadFile``.
The return value of this method is Promise, indicating the success or failure of the upload process.

#### Methods

**constructor(url, userspace, username, password)**

| Name      | Required | Type   | Default | Description                                                             |
|-----------|----------|--------|---------|-------------------------------------------------------------------------|
| url       | yes      | string |         | URL to WebDav API                                                       |
| userspace | yes      | string |         | User key on the filesystem on the server (usually the same as username) |
| username  | yes      | string |         | Credentials: Username                                                   |
| password  | yes      | string |         | Credentials: Password                                                   |

**uploadFile(localPath, remotePath, chunkSize, retryChunks, createDirsRecursively, deleteChunksOnFailure): Promise&lt;Event&gt;**

| Name                      | Required | Type    | Default | Description                                                  |
|---------------------------|----------|---------|---------|--------------------------------------------------------------|
| localPath                 | yes      | string  |         | Path of file on local machine                                |
| remotePath                | yes      | string  |         | Path the file should be placed on the server                 |
| chunkSize                 | no       | number  | 2MB     | The max size of chunks in bytes                              |
| retryChunks               | no       | number  | 5       | Number of retry attempts for uploading a chunk               |
| createDirsRecursively     | no       | boolean | false   | Create sub directories of upload path recursively            | 
| deleteChunksOnFailure[^1] | no       | boolean | false   | Delete uploaded chunk files when the upload operation failed |

[^1]: It's recommended to set this parameter to ``true``. Setting it to ``false`` leads to wasting memory when uploads fail.
The default value is ``false`` to keep compatibility to older versions. 

### Event

`Upload.uploadFile` returns a promise containing an event object. This object holds information about the result of the
upload.

#### Member variables

| Name             | Type    | Description                          |
|------------------|---------|--------------------------------------|
| filename         | string  | Local file path                      |
| chunkNo          | number  | Sequence number of the current chunk |
| message          | string  | Event reason                         |
| complete         | boolean | Whether the upload was successful    |
| httpErrorCode    | number  | HTTP response code, if upload failed |
| httpErrorMessage | string  | HTTP response body, if upload failed |

#### Methods

**toString(): string**

Returns a string containg the event data

### Example

A simple upload code could look like this:

```javascript
const Upload = require('nextcloud-chunk-file-upload');

const upload = new Upload('https://example.com/remote.php/dav', 'myuser', 'myspace', 'secret');

upload.uploadFile('/path/to/localfile.jpg', '/path/to/remotefile.jpg', undefined, undefined, true, true)
  .then(event => {
    console.log('Success!');
    console.log(event.toString());
  })
  .catch(event => {
    console.error('Sth. went wrong')
    console.error(event.toString());
  });
```

## License

This project is licensed under the MIT license. See LICENSE file.

---
_Source: https://npm.io/package/nextcloud-chunk-file-upload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
