# @syyfe/syy-mp-image-server

> 商业云OSS图片处理

Latest version **3.5.0** (published 2025-08-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @syyfe/syy-mp-image-server
pnpm add @syyfe/syy-mp-image-server
yarn add @syyfe/syy-mp-image-server
bun add @syyfe/syy-mp-image-server
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.5.0 |
| Published | 2025-08-19 |
| First published | 2022-06-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | henry.zhou |
| Maintainers | henry.zhou |
| Keywords | oss |

## Links

- npm: https://www.npmjs.com/package/@syyfe/syy-mp-image-server
- npm.io page: https://npm.io/package/@syyfe/syy-mp-image-server

## Dependencies (13)

- [ip](https://npm.io/package/ip.md) ^1.1.8
- [md5](https://npm.io/package/md5.md) ^2.3.0
- [qiniu](https://npm.io/package/qiniu.md) ^7.3.0
- [ali-oss](https://npm.io/package/ali-oss.md) ^6.5.1
- [s3-node](https://npm.io/package/s3-node.md) ^0.0.1
- [relative](https://npm.io/package/relative.md) ^3.0.2
- [portfinder](https://npm.io/package/portfinder.md) ^1.0.28
- [serve-index](https://npm.io/package/serve-index.md) ^1.9.1
- [finalhandler](https://npm.io/package/finalhandler.md) ^1.2.0
- [serve-static](https://npm.io/package/serve-static.md) ^1.15.0
- [esdk-obs-nodejs](https://npm.io/package/esdk-obs-nodejs.md) ^3.25.6
- [cos-nodejs-sdk-v5](https://npm.io/package/cos-nodejs-sdk-v5.md) ^2.9.21
- [@syyfe/syy-utils-node](https://npm.io/package/@syyfe/syy-utils-node.md) ^0.0.5

## Recent versions

- 3.5.0 (latest) — 2025-08-19
- 3.4.3 — 2023-03-31
- 3.4.0 — 2023-01-12
- 3.1.4 — 2022-06-27
- 3.1.3 — 2022-06-23
- 3.1.1 — 2022-06-23
- 3.1.0 — 2022-06-17
- 3.0.9 — 2022-06-16
- 3.0.7 — 2022-06-16
- 3.0.6 — 2022-06-16
- 1.0.0 — 2022-06-16

## README

# 商业云图片服务

开发模式下，开启本地服务器代理访问图片，生产模式时，将小程序内的图片上传到阿里云或七牛云.[@syyfe/syy-mp-service](https://www.npmjs.com/package/@syyfe/syy-mp-service)内置库。

目前支持：腾讯云、阿里云、七牛、UCloud

开发模式支持本地资源文件预览

![avatar](https://syycdn.dongchali.net/dist/syy-fx-mp/a59bee22343839c0c381c9bc47559c14.png)

## 安装

```bash
npm i @syyfe/syy-mp-image-server -S
```

## 使用

```typescript
import { SyyImageServer, IOptions } from "@syyfe/syy-mp-image-server";

const options: IOptions = {
    path: "当前文件夹",
    port: 8989,
    oss: {
        type: "TENCENT",
        options: {
            secretId: "--",
            secretKey: "--",
            bucket: "--",
            region: "--",
            prefix: `--`,
            accessDomain: "--",
            https: true
        }
    }
};

(async (): Promise<void> => {
    const imageOperator = new SyyImageServer(options);
    await imageOperator.Server();
    await imageOperator.Upload();

    console.log(
        imageOperator.GetNetURI(
            "/Users/zhendao/Desktop/Code/framework/syy-mp-new/packages/examples/src/assets/images/auth/4ecbb50f-4c83-4fd5-b940-cf414d06102e.png"
        )
    );
})();
```

## 相关配置

```typescript
/**
 * 阿里配置
 */
export interface IAliOptions {
    bucket: string;
    region: string;
    prefix: string;
    accessKeyId: string;
    accessKeySecret: string;
    fileType?: RegExp;
}

/**
 * 七牛配置
 */
export interface IQiNiuOptions {
    zone: string;
    accessKey: string;
    secretKey: string;
    bucket: string;
    prefix: string;
    domain: string;
    https: boolean;
    fileType?: RegExp;
}

/**
 * Ucloud配置
 */
export interface IUcloudOptions {
    accessKeyId: string;
    secretAccessKey: string;
    bucket: string;
    prefix: string;
    endpoint: string;
    sslEnabled: boolean;
    fileType?: RegExp;
    accessDomain?: string;
}

/**
 * 腾讯OSS配置
 */
export interface ITencentOptions {
    secretId: string;
    secretKey: string;
    bucket: string;
    region: string;
    prefix: string;
    accessDomain: string;
    https: boolean;
    fileType?: RegExp;
}

export interface IOSSOptions {
    type: OSSType;
    options: ITencentOptions | IUcloudOptions | IQiNiuOptions | IAliOptions;
}

export interface IOptions {
    path: string;
    port?: number;
    oss: IOSSOptions;
}

export interface IOSSServer {
    /**
     * 检查文件是否存在
     * @param objectName 文件名称
     */
    CheckFileUpStatus(objectName: string);

    /**
     * 上传文件
     * @param objectName 文件名称
     * @param localFile 当前文件
     */
    Upload(objectName: string, localFile: string);

    /**
     * 上传成功后，获取上传后的图片地址
     * @memberof SyyImageServer
     */
    GetNetURI(localFile): string | void;
}
```

## 感谢

本库参考了 [megalo-image-service](https://github.com/NextBoy/megalo-image-service) 部分代码

---
_Source: https://npm.io/package/@syyfe/syy-mp-image-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
