@simplysm/storage 13.0.100 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -84
- package/dist/clients/ftp-storage-client.d.ts +18 -18
- package/dist/clients/ftp-storage-client.d.ts.map +1 -1
- package/dist/clients/ftp-storage-client.js +127 -116
- package/dist/clients/ftp-storage-client.js.map +1 -6
- package/dist/clients/sftp-storage-client.d.ts +14 -14
- package/dist/clients/sftp-storage-client.d.ts.map +1 -1
- package/dist/clients/sftp-storage-client.js +132 -116
- package/dist/clients/sftp-storage-client.js.map +1 -6
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -6
- package/dist/storage-factory.d.ts +5 -5
- package/dist/storage-factory.js +34 -30
- package/dist/storage-factory.js.map +1 -6
- package/dist/types/storage-conn-config.js +2 -1
- package/dist/types/storage-conn-config.js.map +1 -6
- package/dist/types/storage-type.js +2 -1
- package/dist/types/storage-type.js.map +1 -6
- package/dist/types/storage.js +2 -1
- package/dist/types/storage.js.map +1 -6
- package/package.json +6 -7
- package/src/clients/ftp-storage-client.ts +22 -22
- package/src/clients/sftp-storage-client.ts +28 -28
- package/src/index.ts +3 -3
- package/src/storage-factory.ts +6 -6
- package/tests/ftp-storage-client.spec.ts +0 -261
- package/tests/sftp-storage-client.spec.ts +0 -253
- package/tests/storage-factory.spec.ts +0 -172
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @simplysm/storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Storage client library for FTP, FTPS, and SFTP file operations.
|
|
4
|
+
|
|
5
|
+
Platform: Node.js.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -12,131 +14,121 @@ npm install @simplysm/storage
|
|
|
12
14
|
|
|
13
15
|
### Types
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|-----|------|-------------|
|
|
17
|
-
| `StorageConnConfig` | interface | Storage connection configuration |
|
|
18
|
-
| `FileInfo` | interface | File/directory entry information |
|
|
19
|
-
| `StorageClient` | interface | Storage client interface |
|
|
20
|
-
| `StorageProtocol` | type | Protocol type (`"ftp" \| "ftps" \| "sftp"`) |
|
|
17
|
+
#### StorageConnConfig
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
Connection configuration for storage clients.
|
|
23
20
|
|
|
24
|
-
|
|
|
25
|
-
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
21
|
+
| Field | Type | Description |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `host` | `string` | Server hostname or IP address |
|
|
24
|
+
| `port?` | `number` | Server port (protocol default if omitted) |
|
|
25
|
+
| `user?` | `string` | Username |
|
|
26
|
+
| `password?` | `string` | Password |
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
#### FileInfo
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|-----|------|-------------|
|
|
33
|
-
| `StorageFactory` | class | Storage client factory with managed connections |
|
|
30
|
+
File/directory entry returned by `list()`.
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
| Field | Type | Description |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `name` | `string` | File or directory name |
|
|
35
|
+
| `isFile` | `boolean` | `true` if this entry is a file, `false` if it is a directory |
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
#### StorageProtocol
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
-
type StorageProtocol = "ftp" | "ftps" | "sftp"
|
|
40
|
+
type StorageProtocol = "ftp" | "ftps" | "sftp";
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
#### StorageClient (interface)
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|-------|------|-------------|
|
|
47
|
-
| `host` | `string` | Server hostname |
|
|
48
|
-
| `port` | `number?` | Server port |
|
|
49
|
-
| `user` | `string?` | Username |
|
|
50
|
-
| `password` | `string?` | Password (SFTP: if omitted, uses SSH agent + key file) |
|
|
45
|
+
Common interface implemented by all storage clients.
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
| Method | Signature | Description |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `connect` | `(config: StorageConnConfig) => Promise<void>` | Connect to the server |
|
|
50
|
+
| `mkdir` | `(dirPath: string) => Promise<void>` | Create directory (recursive) |
|
|
51
|
+
| `rename` | `(fromPath: string, toPath: string) => Promise<void>` | Rename a file or directory |
|
|
52
|
+
| `list` | `(dirPath: string) => Promise<FileInfo[]>` | List directory contents |
|
|
53
|
+
| `readFile` | `(filePath: string) => Promise<Bytes>` | Read file contents |
|
|
54
|
+
| `exists` | `(filePath: string) => Promise<boolean>` | Check if file or directory exists |
|
|
55
|
+
| `put` | `(localPathOrBuffer: string \| Bytes, storageFilePath: string) => Promise<void>` | Upload a local file path or byte data to remote path |
|
|
56
|
+
| `uploadDir` | `(fromPath: string, toPath: string) => Promise<void>` | Upload entire local directory to remote path |
|
|
57
|
+
| `remove` | `(filePath: string) => Promise<void>` | Remove a file |
|
|
58
|
+
| `close` | `() => Promise<void>` | Close the connection. Safe to call multiple times. |
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|-------|------|-------------|
|
|
56
|
-
| `name` | `string` | File or directory name |
|
|
57
|
-
| `isFile` | `boolean` | Whether the entry is a file |
|
|
60
|
+
### Clients
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
#### FtpStorageClient
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
FTP/FTPS client. Implements `StorageClient`. Uses `basic-ftp` internally.
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
| `mkdir` | `(dirPath: string) => Promise<void>` | Create directory (recursive) |
|
|
67
|
-
| `rename` | `(fromPath: string, toPath: string) => Promise<void>` | Rename file/directory |
|
|
68
|
-
| `list` | `(dirPath: string) => Promise<FileInfo[]>` | List directory contents |
|
|
69
|
-
| `readFile` | `(filePath: string) => Promise<Bytes>` | Read file |
|
|
70
|
-
| `exists` | `(filePath: string) => Promise<boolean>` | Check existence |
|
|
71
|
-
| `put` | `(localPathOrBuffer: string \| Bytes, storageFilePath: string) => Promise<void>` | Upload file (local path or byte data) |
|
|
72
|
-
| `uploadDir` | `(fromPath: string, toPath: string) => Promise<void>` | Upload entire directory |
|
|
73
|
-
| `remove` | `(filePath: string) => Promise<void>` | Delete file |
|
|
74
|
-
| `close` | `() => Promise<void>` | Close connection |
|
|
66
|
+
```typescript
|
|
67
|
+
constructor(secure?: boolean)
|
|
68
|
+
```
|
|
75
69
|
|
|
76
|
-
|
|
70
|
+
| Parameter | Type | Default | Description |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| `secure` | `boolean` | `false` | Set `true` for FTPS |
|
|
77
73
|
|
|
78
|
-
|
|
74
|
+
All methods from `StorageClient` are implemented. Prefer using `StorageFactory.connect` over direct instantiation.
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|--------|-----------|-------------|
|
|
82
|
-
| `constructor` | `(secure?: boolean)` | Create client (`true` for FTPS, `false` for FTP) |
|
|
76
|
+
#### SftpStorageClient
|
|
83
77
|
|
|
84
|
-
|
|
78
|
+
SFTP client. Implements `StorageClient`. Uses `ssh2-sftp-client` internally.
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
```typescript
|
|
81
|
+
constructor()
|
|
82
|
+
```
|
|
87
83
|
|
|
88
|
-
|
|
84
|
+
Authentication priority when `password` is not provided:
|
|
85
|
+
1. SSH private key (`~/.ssh/id_ed25519`) + SSH agent
|
|
86
|
+
2. SSH agent only (fallback when key parsing fails)
|
|
89
87
|
|
|
90
|
-
All `StorageClient`
|
|
88
|
+
All methods from `StorageClient` are implemented. Prefer using `StorageFactory.connect` over direct instantiation.
|
|
91
89
|
|
|
92
|
-
###
|
|
90
|
+
### Factory
|
|
91
|
+
|
|
92
|
+
#### StorageFactory
|
|
93
|
+
|
|
94
|
+
Static factory class for creating and managing storage connections.
|
|
95
|
+
|
|
96
|
+
##### Static Methods
|
|
93
97
|
|
|
94
98
|
| Method | Signature | Description |
|
|
95
|
-
|
|
96
|
-
| `connect` | `<R>(type: StorageProtocol, config: StorageConnConfig, fn: (storage: StorageClient) => R \| Promise<R>) => Promise<R>` | Connect, execute callback,
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `connect` | `<R>(type: StorageProtocol, config: StorageConnConfig, fn: (storage: StorageClient) => R \| Promise<R>) => Promise<R>` | Connect to storage, execute callback, and automatically close the connection. The connection is closed even if the callback throws. |
|
|
97
101
|
|
|
98
|
-
## Usage
|
|
102
|
+
## Usage
|
|
99
103
|
|
|
100
|
-
###
|
|
104
|
+
### Recommended: StorageFactory (auto-managed connection)
|
|
101
105
|
|
|
102
106
|
```typescript
|
|
103
107
|
import { StorageFactory } from "@simplysm/storage";
|
|
104
108
|
|
|
105
|
-
await StorageFactory.connect("sftp", {
|
|
109
|
+
const files = await StorageFactory.connect("sftp", {
|
|
106
110
|
host: "example.com",
|
|
107
111
|
user: "deploy",
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
await
|
|
111
|
-
|
|
112
|
+
}, async (client) => {
|
|
113
|
+
await client.mkdir("/remote/path");
|
|
114
|
+
await client.put("/local/file.txt", "/remote/file.txt");
|
|
115
|
+
return client.list("/remote/path");
|
|
112
116
|
});
|
|
113
117
|
```
|
|
114
118
|
|
|
115
|
-
###
|
|
119
|
+
### Direct client usage
|
|
116
120
|
|
|
117
121
|
```typescript
|
|
118
|
-
import {
|
|
122
|
+
import { SftpStorageClient } from "@simplysm/storage";
|
|
119
123
|
|
|
120
|
-
const client = new
|
|
121
|
-
await client.connect({ host: "
|
|
124
|
+
const client = new SftpStorageClient();
|
|
125
|
+
await client.connect({ host: "example.com", user: "deploy" });
|
|
122
126
|
try {
|
|
123
|
-
await client.
|
|
124
|
-
|
|
127
|
+
const exists = await client.exists("/remote/file.txt");
|
|
128
|
+
if (exists) {
|
|
129
|
+
const data = await client.readFile("/remote/file.txt");
|
|
130
|
+
}
|
|
125
131
|
} finally {
|
|
126
132
|
await client.close();
|
|
127
133
|
}
|
|
128
134
|
```
|
|
129
|
-
|
|
130
|
-
### SFTP with SSH key authentication
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
import { StorageFactory } from "@simplysm/storage";
|
|
134
|
-
|
|
135
|
-
// Omit password to use SSH agent + ~/.ssh/id_ed25519
|
|
136
|
-
await StorageFactory.connect("sftp", {
|
|
137
|
-
host: "example.com",
|
|
138
|
-
user: "deploy",
|
|
139
|
-
}, async (storage) => {
|
|
140
|
-
await storage.put(fileBytes, "/data/upload.bin");
|
|
141
|
-
});
|
|
142
|
-
```
|
|
@@ -2,54 +2,54 @@ import type { Bytes } from "@simplysm/core-common";
|
|
|
2
2
|
import type { StorageClient, FileInfo } from "../types/storage";
|
|
3
3
|
import type { StorageConnConfig } from "../types/storage-conn-config";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* FTP/FTPS 프로토콜을 사용하는 스토리지 클라이언트.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* `secure` 생성자 매개변수로 FTPS 사용 여부를 설정합니다.
|
|
9
|
+
* 직접 사용하기보다 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
10
10
|
*/
|
|
11
11
|
export declare class FtpStorageClient implements StorageClient {
|
|
12
12
|
private readonly _secure;
|
|
13
13
|
private _client;
|
|
14
14
|
constructor(_secure?: boolean);
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* FTP 서버에 연결합니다.
|
|
17
17
|
*
|
|
18
18
|
* @remarks
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
21
|
-
* -
|
|
19
|
+
* - 사용 후 {@link close}로 연결을 종료해야 합니다.
|
|
20
|
+
* - 동일 인스턴스에서 여러 번 호출하지 마세요 (연결 누수).
|
|
21
|
+
* - 자동 연결/종료 관리를 위해 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
22
22
|
*/
|
|
23
23
|
connect(config: StorageConnConfig): Promise<void>;
|
|
24
24
|
private _requireClient;
|
|
25
|
-
/**
|
|
25
|
+
/** 디렉토리를 생성합니다. 부모 디렉토리가 없으면 함께 생성합니다. */
|
|
26
26
|
mkdir(dirPath: string): Promise<void>;
|
|
27
27
|
rename(fromPath: string, toPath: string): Promise<void>;
|
|
28
28
|
list(dirPath: string): Promise<FileInfo[]>;
|
|
29
29
|
readFile(filePath: string): Promise<Bytes>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 파일 또는 디렉토리의 존재 여부를 확인합니다.
|
|
32
32
|
*
|
|
33
33
|
* @remarks
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* 파일의 경우 size() 명령으로 O(1) 성능을 제공합니다.
|
|
35
|
+
* 디렉토리의 경우 부모 디렉토리 목록을 조회하므로 항목이 많으면 성능이 저하될 수 있습니다.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
37
|
+
* 슬래시가 없는 경로(예: `file.txt`)는 루트 디렉토리(`/`)에서 검색합니다.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* 부모 디렉토리가 존재하지 않아도 false를 반환합니다.
|
|
40
|
+
* 네트워크 오류, 권한 오류 등 모든 예외에 대해 false를 반환합니다.
|
|
41
41
|
*/
|
|
42
42
|
exists(filePath: string): Promise<boolean>;
|
|
43
43
|
remove(filePath: string): Promise<void>;
|
|
44
|
-
/**
|
|
44
|
+
/** 로컬 파일 경로 또는 바이트 데이터를 원격 경로에 업로드합니다. */
|
|
45
45
|
put(localPathOrBuffer: string | Bytes, storageFilePath: string): Promise<void>;
|
|
46
46
|
uploadDir(fromPath: string, toPath: string): Promise<void>;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* 연결을 종료합니다.
|
|
49
49
|
*
|
|
50
50
|
* @remarks
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* 이미 종료된 상태에서 호출해도 안전합니다 (오류 미발생).
|
|
52
|
+
* 종료 후 동일 인스턴스에서 {@link connect}를 다시 호출하여 재연결할 수 있습니다.
|
|
53
53
|
*/
|
|
54
54
|
close(): Promise<void>;
|
|
55
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ftp-storage-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\clients\\ftp-storage-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAGxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,OAAO,CAAyB;gBAEX,OAAO,GAAE,OAAe;IAErD;;;;;;;OAOG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvD,OAAO,CAAC,cAAc;IAOtB,
|
|
1
|
+
{"version":3,"file":"ftp-storage-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\clients\\ftp-storage-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAGxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,OAAO,CAAyB;gBAEX,OAAO,GAAE,OAAe;IAErD;;;;;;;OAOG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvD,OAAO,CAAC,cAAc;IAOtB,0CAA0C;IACpC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAK1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAWhD;;;;;;;;;;;OAWG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,0CAA0C;IACpC,GAAG,CAAC,iBAAiB,EAAE,MAAM,GAAG,KAAK,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9E,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE;;;;;;OAMG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CASvB"}
|
|
@@ -1,126 +1,137 @@
|
|
|
1
1
|
import { bytes, SdError } from "@simplysm/core-common";
|
|
2
2
|
import ftp from "basic-ftp";
|
|
3
3
|
import { PassThrough, Readable } from "stream";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
async connect(config) {
|
|
18
|
-
if (this._client !== void 0) {
|
|
19
|
-
throw new SdError("FTP server is already connected. Please call close() first.");
|
|
4
|
+
/**
|
|
5
|
+
* FTP/FTPS 프로토콜을 사용하는 스토리지 클라이언트.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* `secure` 생성자 매개변수로 FTPS 사용 여부를 설정합니다.
|
|
9
|
+
* 직접 사용하기보다 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
10
|
+
*/
|
|
11
|
+
export class FtpStorageClient {
|
|
12
|
+
_secure;
|
|
13
|
+
_client;
|
|
14
|
+
constructor(_secure = false) {
|
|
15
|
+
this._secure = _secure;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
/**
|
|
18
|
+
* FTP 서버에 연결합니다.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* - 사용 후 {@link close}로 연결을 종료해야 합니다.
|
|
22
|
+
* - 동일 인스턴스에서 여러 번 호출하지 마세요 (연결 누수).
|
|
23
|
+
* - 자동 연결/종료 관리를 위해 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
24
|
+
*/
|
|
25
|
+
async connect(config) {
|
|
26
|
+
if (this._client !== undefined) {
|
|
27
|
+
throw new SdError("FTP 서버에 이미 연결되어 있습니다. 먼저 close()를 호출해 주세요.");
|
|
28
|
+
}
|
|
29
|
+
const client = new ftp.Client();
|
|
30
|
+
try {
|
|
31
|
+
await client.access({
|
|
32
|
+
host: config.host,
|
|
33
|
+
port: config.port,
|
|
34
|
+
user: config.user,
|
|
35
|
+
password: config.password,
|
|
36
|
+
secure: this._secure,
|
|
37
|
+
});
|
|
38
|
+
this._client = client;
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
client.close();
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
_requireClient() {
|
|
46
|
+
if (this._client === undefined) {
|
|
47
|
+
throw new SdError("FTP 서버에 연결되어 있지 않습니다.");
|
|
48
|
+
}
|
|
49
|
+
return this._client;
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
async mkdir(dirPath) {
|
|
44
|
-
await this._requireClient().ensureDir(dirPath);
|
|
45
|
-
}
|
|
46
|
-
async rename(fromPath, toPath) {
|
|
47
|
-
await this._requireClient().rename(fromPath, toPath);
|
|
48
|
-
}
|
|
49
|
-
async list(dirPath) {
|
|
50
|
-
const fileInfos = await this._requireClient().list(dirPath);
|
|
51
|
-
return fileInfos.map((item) => ({ name: item.name, isFile: item.isFile }));
|
|
52
|
-
}
|
|
53
|
-
async readFile(filePath) {
|
|
54
|
-
const client = this._requireClient();
|
|
55
|
-
const chunks = [];
|
|
56
|
-
const writable = new PassThrough();
|
|
57
|
-
writable.on("data", (chunk) => {
|
|
58
|
-
chunks.push(chunk);
|
|
59
|
-
});
|
|
60
|
-
await client.downloadTo(writable, filePath);
|
|
61
|
-
return bytes.concat(chunks);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Check whether a file or directory exists.
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* For files, uses the size() command for O(1) performance.
|
|
68
|
-
* For directories, queries the parent directory listing, so performance may degrade with many entries.
|
|
69
|
-
*
|
|
70
|
-
* Paths without slashes (e.g. `file.txt`) are searched in the root directory (`/`).
|
|
71
|
-
*
|
|
72
|
-
* Returns false even if the parent directory does not exist.
|
|
73
|
-
* Returns false for all exceptions including network errors and permission errors.
|
|
74
|
-
*/
|
|
75
|
-
async exists(filePath) {
|
|
76
|
-
try {
|
|
77
|
-
await this._requireClient().size(filePath);
|
|
78
|
-
return true;
|
|
79
|
-
} catch {
|
|
80
|
-
try {
|
|
81
|
-
const lastSlash = filePath.lastIndexOf("/");
|
|
82
|
-
const dirPath = lastSlash > 0 ? filePath.substring(0, lastSlash) : "/";
|
|
83
|
-
const fileName = filePath.substring(lastSlash + 1);
|
|
84
|
-
const list = await this._requireClient().list(dirPath);
|
|
85
|
-
return list.some((item) => item.name === fileName);
|
|
86
|
-
} catch {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
51
|
+
/** 디렉토리를 생성합니다. 부모 디렉토리가 없으면 함께 생성합니다. */
|
|
52
|
+
async mkdir(dirPath) {
|
|
53
|
+
await this._requireClient().ensureDir(dirPath);
|
|
89
54
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
await this._requireClient().remove(filePath);
|
|
93
|
-
}
|
|
94
|
-
/** Upload a local file path or byte data to the remote path. */
|
|
95
|
-
async put(localPathOrBuffer, storageFilePath) {
|
|
96
|
-
let param;
|
|
97
|
-
if (typeof localPathOrBuffer === "string") {
|
|
98
|
-
param = localPathOrBuffer;
|
|
99
|
-
} else {
|
|
100
|
-
param = Readable.from(localPathOrBuffer);
|
|
55
|
+
async rename(fromPath, toPath) {
|
|
56
|
+
await this._requireClient().rename(fromPath, toPath);
|
|
101
57
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
58
|
+
async list(dirPath) {
|
|
59
|
+
const fileInfos = await this._requireClient().list(dirPath);
|
|
60
|
+
return fileInfos.map((item) => ({ name: item.name, isFile: item.isFile }));
|
|
61
|
+
}
|
|
62
|
+
async readFile(filePath) {
|
|
63
|
+
const client = this._requireClient();
|
|
64
|
+
const chunks = [];
|
|
65
|
+
const writable = new PassThrough();
|
|
66
|
+
writable.on("data", (chunk) => {
|
|
67
|
+
chunks.push(chunk);
|
|
68
|
+
});
|
|
69
|
+
await client.downloadTo(writable, filePath);
|
|
70
|
+
return bytes.concat(chunks);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 파일 또는 디렉토리의 존재 여부를 확인합니다.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* 파일의 경우 size() 명령으로 O(1) 성능을 제공합니다.
|
|
77
|
+
* 디렉토리의 경우 부모 디렉토리 목록을 조회하므로 항목이 많으면 성능이 저하될 수 있습니다.
|
|
78
|
+
*
|
|
79
|
+
* 슬래시가 없는 경로(예: `file.txt`)는 루트 디렉토리(`/`)에서 검색합니다.
|
|
80
|
+
*
|
|
81
|
+
* 부모 디렉토리가 존재하지 않아도 false를 반환합니다.
|
|
82
|
+
* 네트워크 오류, 권한 오류 등 모든 예외에 대해 false를 반환합니다.
|
|
83
|
+
*/
|
|
84
|
+
async exists(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
// size()로 파일 존재 여부 빠른 확인 (O(1))
|
|
87
|
+
await this._requireClient().size(filePath);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// size() 실패 시 디렉토리일 수 있으므로 list()로 확인
|
|
92
|
+
try {
|
|
93
|
+
const lastSlash = filePath.lastIndexOf("/");
|
|
94
|
+
const dirPath = lastSlash > 0 ? filePath.substring(0, lastSlash) : "/";
|
|
95
|
+
const fileName = filePath.substring(lastSlash + 1);
|
|
96
|
+
const list = await this._requireClient().list(dirPath);
|
|
97
|
+
return list.some((item) => item.name === fileName);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async remove(filePath) {
|
|
105
|
+
await this._requireClient().remove(filePath);
|
|
106
|
+
}
|
|
107
|
+
/** 로컬 파일 경로 또는 바이트 데이터를 원격 경로에 업로드합니다. */
|
|
108
|
+
async put(localPathOrBuffer, storageFilePath) {
|
|
109
|
+
let param;
|
|
110
|
+
if (typeof localPathOrBuffer === "string") {
|
|
111
|
+
param = localPathOrBuffer;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
param = Readable.from(localPathOrBuffer);
|
|
115
|
+
}
|
|
116
|
+
await this._requireClient().uploadFrom(param, storageFilePath);
|
|
117
|
+
}
|
|
118
|
+
async uploadDir(fromPath, toPath) {
|
|
119
|
+
await this._requireClient().uploadFromDir(fromPath, toPath);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 연결을 종료합니다.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* 이미 종료된 상태에서 호출해도 안전합니다 (오류 미발생).
|
|
126
|
+
* 종료 후 동일 인스턴스에서 {@link connect}를 다시 호출하여 재연결할 수 있습니다.
|
|
127
|
+
*/
|
|
128
|
+
close() {
|
|
129
|
+
if (this._client === undefined) {
|
|
130
|
+
return Promise.resolve();
|
|
131
|
+
}
|
|
132
|
+
this._client.close();
|
|
133
|
+
this._client = undefined;
|
|
134
|
+
return Promise.resolve();
|
|
117
135
|
}
|
|
118
|
-
this._client.close();
|
|
119
|
-
this._client = void 0;
|
|
120
|
-
return Promise.resolve();
|
|
121
|
-
}
|
|
122
136
|
}
|
|
123
|
-
|
|
124
|
-
FtpStorageClient
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=ftp-storage-client.js.map
|
|
137
|
+
//# sourceMappingURL=ftp-storage-client.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/clients/ftp-storage-client.ts"],
|
|
4
|
-
"mappings": "AACA,SAAS,OAAO,eAAe;AAC/B,OAAO,SAAS;AAChB,SAAS,aAAa,gBAAgB;AAW/B,MAAM,iBAA0C;AAAA,EAGrD,YAA6B,UAAmB,OAAO;AAA1B;AAAA,EAA2B;AAAA,EAFhD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYR,MAAM,QAAQ,QAA0C;AACtD,QAAI,KAAK,YAAY,QAAW;AAC9B,YAAM,IAAI,QAAQ,6DAA6D;AAAA,IACjF;AACA,UAAM,SAAS,IAAI,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C,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -2,46 +2,46 @@ import type { Bytes } from "@simplysm/core-common";
|
|
|
2
2
|
import type { StorageClient, FileInfo } from "../types/storage";
|
|
3
3
|
import type { StorageConnConfig } from "../types/storage-conn-config";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* SFTP 프로토콜을 사용하는 스토리지 클라이언트.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
*
|
|
8
|
+
* 직접 사용하기보다 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
9
9
|
*/
|
|
10
10
|
export declare class SftpStorageClient implements StorageClient {
|
|
11
11
|
private _client;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* SFTP 서버에 연결합니다.
|
|
14
14
|
*
|
|
15
15
|
* @remarks
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
18
|
-
* -
|
|
16
|
+
* - 사용 후 {@link close}로 연결을 종료해야 합니다.
|
|
17
|
+
* - 동일 인스턴스에서 여러 번 호출하지 마세요 (연결 누수).
|
|
18
|
+
* - 자동 연결/종료 관리를 위해 {@link StorageFactory.connect} 사용을 권장합니다.
|
|
19
19
|
*/
|
|
20
20
|
connect(config: StorageConnConfig): Promise<void>;
|
|
21
21
|
private _requireClient;
|
|
22
|
-
/**
|
|
22
|
+
/** 디렉토리를 생성합니다. 부모 디렉토리가 없으면 함께 생성합니다. */
|
|
23
23
|
mkdir(dirPath: string): Promise<void>;
|
|
24
24
|
rename(fromPath: string, toPath: string): Promise<void>;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* 파일 또는 디렉토리의 존재 여부를 확인합니다.
|
|
27
27
|
*
|
|
28
28
|
* @remarks
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* 부모 디렉토리가 존재하지 않아도 false를 반환합니다.
|
|
30
|
+
* 네트워크 오류, 권한 오류 등 모든 예외에 대해 false를 반환합니다.
|
|
31
31
|
*/
|
|
32
32
|
exists(filePath: string): Promise<boolean>;
|
|
33
33
|
list(dirPath: string): Promise<FileInfo[]>;
|
|
34
34
|
readFile(filePath: string): Promise<Bytes>;
|
|
35
35
|
remove(filePath: string): Promise<void>;
|
|
36
|
-
/**
|
|
36
|
+
/** 로컬 파일 경로 또는 바이트 데이터를 원격 경로에 업로드합니다. */
|
|
37
37
|
put(localPathOrBuffer: string | Bytes, storageFilePath: string): Promise<void>;
|
|
38
38
|
uploadDir(fromPath: string, toPath: string): Promise<void>;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 연결을 종료합니다.
|
|
41
41
|
*
|
|
42
42
|
* @remarks
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* 이미 종료된 상태에서 호출해도 안전합니다 (오류 미발생).
|
|
44
|
+
* 종료 후 동일 인스턴스에서 {@link connect}를 다시 호출하여 재연결할 수 있습니다.
|
|
45
45
|
*/
|
|
46
46
|
close(): Promise<void>;
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sftp-storage-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\clients\\sftp-storage-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"sftp-storage-client.d.ts","sourceRoot":"","sources":["..\\..\\src\\clients\\sftp-storage-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKtE;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACrD,O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