-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathindex.ts
More file actions
31 lines (26 loc) · 821 Bytes
/
index.ts
File metadata and controls
31 lines (26 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { IReleaseUploader } from "../interface.js";
import { ipfsAddFromFs } from "./addFromFs.js";
import { normalizeIpfsProvider } from "./ipfsProvider.js";
import { verifyIpfsConnection } from "./verifyConnection.js";
export class ReleaseUploaderIpfsNode implements IReleaseUploader {
networkName = "IPFS node";
apiUrl: string;
constructor({ ipfsProvider }: { ipfsProvider: string }) {
this.apiUrl = normalizeIpfsProvider(ipfsProvider);
}
async addFromFs({
dirPath,
onProgress
}: {
dirPath: string;
onProgress?: (percent: number) => void;
}): Promise<string> {
return await ipfsAddFromFs(dirPath, this.apiUrl, onProgress);
}
async testConnection(): Promise<void> {
await verifyIpfsConnection(this.apiUrl);
}
ipfsApiUrl(): string {
return this.apiUrl;
}
}