# @adobe/httptransfer

> Efficient File Transfer Module for NodeJS

Latest version **5.0.0** (published 2025-03-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @adobe/httptransfer
pnpm add @adobe/httptransfer
yarn add @adobe/httptransfer
bun add @adobe/httptransfer
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-03-20 |
| First published | 2020-04-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 959.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Adobe Inc. |
| Maintainers | marbec, tripod, garthdb, lazd, adobe-admin, patrickfulton, trieloff, shazron, krisnye, dcpfsdk, natebaldwin, devongovett, aspro83, symanovi, dpfister, stefan-guggisberg, rofe, kptdobe, adobehalls, fullcolorcoder, djaeggi, dylandepass, mhaack, amol-anand, stopp-adobe, doten, duh_schmidt, asthabh23, zdahbi, tuicu |
| Keywords | cloud, transfer, http, https, file, blob |

## Links

- npm: https://www.npmjs.com/package/@adobe/httptransfer
- Repository: https://github.com/adobe/node-httptransfer
- Homepage: https://github.com/adobe/node-httptransfer#readme
- Issues: https://github.com/adobe/node-httptransfer/issues
- npm.io page: https://npm.io/package/@adobe/httptransfer

## Dependencies (13)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [drange](https://npm.io/package/drange.md) ^2.0.1
- [core-js](https://npm.io/package/core-js.md) ^3.30.2
- [file-url](https://npm.io/package/file-url.md) 2.0.2
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [valid-url](https://npm.io/package/valid-url.md) ^1.0.9
- [filter-obj](https://npm.io/package/filter-obj.md) ^2.0.2
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.35
- [content-type](https://npm.io/package/content-type.md) ^1.0.5
- [content-range](https://npm.io/package/content-range.md) ^2.0.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.22.3
- [node-fetch-npm](https://npm.io/package/node-fetch-npm.md) ^2.0.4
- [content-disposition](https://npm.io/package/content-disposition.md) ^0.5.4

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2025-03-20
- 4.0.1 — 2025-03-20
- 4.0.0 — 2024-05-31
- 3.4.1 — 2023-07-26
- 3.4.0 — 2023-06-02
- 3.3.1 — 2023-05-25
- 3.3.0 — 2023-01-19
- 3.2.1 — 2022-05-31
- 3.2.0 — 2022-03-31
- 3.1.6 — 2022-03-30
- 3.1.5 — 2022-03-29
- 3.1.4 — 2022-03-28
- 3.1.3 — 2022-02-25
- 3.1.2 — 2022-01-14
- 3.1.1 — 2022-01-14
- … 21 more at https://npm.io/package/@adobe/httptransfer/versions

## README

# node-httptransfer

[![Version](https://img.shields.io/npm/v/@adobe/httptransfer.svg)](https://npmjs.org/package/@adobe/httptransfer)

## Introduction

The `node-httptransfer` package is designed to easily and correctly transfer file content from HTTP(S) urls to HTTP(S) urls and between HTTP(S) urls.

The lower-level stream API allows you to transfer content from a URL to any writable stream, and similarly transfer any readable stream to a URL.

The higher-level file API abstracts away the streams and allows you to transfer content to/from files on disk.

The `node-httptransfer` package requires the async/await features and is built using the [node-fetch-npm](https://www.npmjs.com/package/node-fetch-npm) package.

To use block transfer capabilities, the upload/download servers must support the range header.

## Installation

```bash
npm i @adobe/httptransfer
```

## Using streams

Download a stream:

```javascript
const { downloadStream } = require('@adobe/httptransfer');
async main() {
    const stream = fs.createWriteStream('test.png');
    await downloadStream('http://my.server.com/test.png', stream);
}
```

Upload a stream using PUT:

```javascript
const { uploadStream } = require('@adobe/httptransfer');
async main() {
    const stream = fs.createReadStream('test.png');
    await uploadStream(stream, 'http://my.server.com/test.png');
}
```

## Using files

Download a file:

```javascript
const { downloadFile } = require('@adobe/httptransfer');
async main() {
    await downloadFile('http://my.server.com/test.png', 'test.png');
}
```

Upload a file using PUT:

```javascript
const { uploadFile } = require('@adobe/httptransfer');
async main() {
    await uploadFile('test.png', 'http://my.server.com/test.png');
}
```

Upload a file to multiple URLs using PUT (used by AEM multi-part upload):

```javascript
const { uploadAEMMultipartFile } = require('@adobe/httptransfer');
async main() {
    await uploadAEMMultipartFile('test.png', {
        urls: [ "http://my.server.com/test.png.1", "http://my.server.com/test.png.2" ],
        maxPartSize: 1000000
    });
}
```
## Using block upload/downland to upload/download files concurrently
```javascript
const { downloadFileConcurrently } = require('@adobe/httptransfer');
async main() {
    await downloadFile('http://my.server.com/test.png', 'test.png');
}
```

Upload a file using PUT:

```javascript
const { uploadFileConcurrently } = require('@adobe/httptransfer');
async main() {
    await uploadFile('test.png', 'http://my.server.com/test.png');
}
```

Upload a file to multiple URLs using PUT (used by AEM multi-part upload):

```javascript
const { uploadMultiPartFileConcurrently } = require('@adobe/httptransfer');
async main() {
    await uploadMultiPartFileConcurrently('test.png', {
        urls: [ "http://my.server.com/test.png.1", "http://my.server.com/test.png.2" ],
        maxPartSize: 1000000
    });
}
```


Upload multiple files to multiple URLs using PUT:

```javascript
const { uploadFilesConcurrently } = require('@adobe/httptransfer');
async main() {
    await uploadFilesConcurrently([{
        filepath: 'file1.png',
        target: {
            urls: [ "http://my.server.com/file1.png.1", "http://my.server.com/file1.png.2" ],
            maxPartSize: 1000000
        }
    }], {
        filepath: 'file2.png',
        target: {
            urls: [ "http://my.server.com/file2.png.1", "http://my.server.com/file2.png.2" ],
            maxPartSize: 1000000
        }
    }]);
}
```

Assuming `test.png` is 1,800,000 bytes this will upload the first 1,000,000 bytes to `http://my.server.com/test.png.1` and the next 800,000 bytes to `http://my.server.com/test.png.2`.

## Debugging
To enable debug output when using `node-httptransfer` library, set the `DEBUG` environment variable to `httptransfer:*`.
You can also specify a specific loglevel per [./lib/logger.js](./lib/logger.js), e.g.: 

```bash
$ DEBUG='httptransfer:warn' npm run test
```

## Testbed

A CLI tool [testbed](./testbed/index.js) is provided to try out the `node-httptransfer` functionality. It supports uploading, downloading, and transferring file content. It also supports Azure Blob stores through Shared Access Signature (SAS) urls created on the fly.

The tool is not intended to be useful on its own, only to test out new features or debug issues.

### Build

```bash
cd testbed/
npm install
```

### Azure credentials

```bash
export AZURE_STORAGE_ACCOUNT=<storage account name from https://portal.azure.com>
export AZURE_STORAGE_KEY=<storage key from https://portal.azure.com>
```

### Examples

Download an image from a website:

```bash
node index.js https://website.com/path/to/image.gif image.gif
```

Download blob.txt from azure:

```bash
node index.js azure://container/path/to/blob.txt blob.txt
```

Upload blob.txt to azure:

```bash
node index.js blob.txt azure://container/path/to/blob.txt
```

Upload blob.txt in 10,000 byte blocks:

```bash
node index.js --max 10000 blob.txt azure://container/path/to/blob.txt
```

Copy blob.txt within a container:

```bash
node index.js azure://container/path/to/blob.txt azure://container/path/to/target.txt
```

## End-to-End Tests

The module provides some integration-style tests for verifying basic transfer functionality
with an Adobe Experience Manager instance. To run the tests:

* Create a `.env` file by following the instructions in [.env_example](./e2e/.env_example).
* Run the tests by executing `npm run e2e` from the root directory of the repository.

## End-to-End block upload/download Tests
If you want to just run the block upload/download tests, you only need [Azure credentials](#Azure-credentials):

```bash
export AZURE_STORAGE_ACCOUNT=<storage account name from https://portal.azure.com>
export AZURE_STORAGE_KEY=<storage key from https://portal.azure.com>
export AZURE_STORAGE_CONTAINER_NAME=<storage container name>
```

The run `npm run e2e-block`

### Contributing

Contributions are welcomed! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information.

### Licensing

This project is licensed under the Apache V2 License. See [LICENSE](LICENSE) for more information.

---
_Source: https://npm.io/package/@adobe/httptransfer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
