# @adobe/httptransfer 中文文档

规范地址：https://npmcn.com/package/%40adobe/httptransfer/

版本：5\.0\.0
npm 元数据更新时间：2026-10-01T01:33:43.383Z
中文译文更新时间：2026-11-05T21:49:29.651Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40adobe/httptransfer
原文对照：https://npmcn.com/package/%40adobe/httptransfer/?lang=original
项目主页：https://github.com/adobe/node-httptransfer#readme
源码仓库：https://github.com/adobe/node-httptransfer

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：983 kB，115 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：13 个
- 首次发布：2020-04-27T20:33:39.451Z
- 最新版本发布：2025-03-20T00:46:11.170Z
- 近 30 天下载量：15508（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：37（近 12 个月 0 个）

## 中文简介

节点JS高效文件传输模块

## 安装

```sh
npm install @adobe/httptransfer
```

也可以使用：`pnpm add @adobe/httptransfer`、`yarn add @adobe/httptransfer`、`bun add @adobe/httptransfer`

## README

# 节点- httptransfer

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

## 导言

这个 `node-httptransfer` 软件包的设计是为了方便和正确地将文件内容从HTTP(S) urls转移到HTTP(S) urls之间以及HTTP(S) urls之间.

下等流 API 允许您将内容从 URL 传输到任何可写流, 并且同样将任何可读流传输到 URL .

高级文件 API 摘要将流移出, 并允许您将内容传输到磁盘上的文件 .

这个 `node-httptransfer` 软件包需要async/await特性,并使用 [节点比对npm](https://www.npmjs.com/package/node-fetch-npm) 软件包.

要使用块传输能力,上传/下载服务器必须支持范围头.

## 安装

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

## 使用流

下载流 :

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

使用 PUT 上传流 :

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

## 使用文件

下载文件 :

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

使用 PUT 上传文件 :

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

使用 PUT( 由 AEM 多段上传使用) 上传到多个 URL 的文件 :

```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
    });
}
```

## 使用块上传/下行区域同时上传/下行文件

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

使用 PUT 上传文件 :

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

使用 PUT( 由 AEM 多段上传使用) 上传到多个 URL 的文件 :

```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
    });
}
```

使用 PUT 上传多个文件到多个 URL :

```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
        }
    }]);
}
```

假设 `test.png` 1,800,000个字节将上传到 `http://my.server.com/test.png.1` 后80万字节改为 `http://my.server.com/test.png.2`。 。 。 .

## 调试

在使用时启用调试输出 `node-httptransfer` 库,设置 `DEBUG` 环境变量改为 `httptransfer:*`。 。 。 . 您也可以指定每个日志级别 [./lib/logger.js (英语)](https://npmcn.com/package/%40adobe/httptransfer/lib/logger.js),例如:

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

## 测试台

CLI 工具 [测试床](https://npmcn.com/package/%40adobe/httptransfer/testbed/index.js) 用于测试 `node-httptransfer` 函数。 它支持上传,下载,以及转移文件内容. 它还通过在苍蝇上创建的共享访问签名(SAS)urls支持Azure Blob商店.

该工具并不打算单独有用,只是为了测试新特性或调试问题.

### 构建

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

### Azure 证书

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

### 实例

从网站上下载图像 :

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

从 Azure 下载 blob.txt :

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

上传 blob.txt 到 azure :

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

以一万字节块上传 blob.txt :

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

在容器内复制 blob.txt :

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

## 端到端测试

该模块为验证基本传输功能提供了一些集成式测试 与 Adobe 经验管理器实例。 为了进行测试:

-   创建一个 `.env` 通过遵循在 [.env 实例](https://npmcn.com/package/%40adobe/httptransfer/e2e/.env_example)。 。 。 .
-   通过执行运行测试 `npm run e2e` 从寄存器的根目录.

## 端到端块上传/下载测试

如果你想只是运行块上传/下载测试,只需要 [Azure 证书](https://npmcn.com/package/%40adobe/httptransfer/#readme-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>
```

运行 `npm run e2e-block`

### 捐款

欢迎捐款! 读取 [贡献指南](https://npmcn.com/package/%40adobe/httptransfer/.github/CONTRIBUTING.md) 更多信息.

### 许可证发放

这个项目根据Apache V2许可证获得许可. 见 [自由主义](https://npmcn.com/package/%40adobe/httptransfer/LICENSE) 更多信息.

## 常见问题

### @adobe/httptransfer 是什么？

节点JS高效文件传输模块

### 如何安装 @adobe/httptransfer？

在项目目录运行 npm install @adobe/httptransfer，或使用 pnpm add / yarn add / bun add。

### @adobe/httptransfer 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/adobe\_\_httptransfer 是否存在。

### @adobe/httptransfer 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @adobe/httptransfer 可以商用吗？

@adobe/httptransfer 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @adobe/httptransfer 的下载量有多少？

根据 npm 官方下载统计，@adobe/httptransfer 在 2026/10/05 – 2026/11/03 这 30 天内被下载 15,508 次，日均约 517 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @adobe/httptransfer 还在维护吗？

最新版本 5\.0\.0 发布于 2025/03/20（1\.6 年前）；至今共发布 37 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/04/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

