Skip to content

Commit 0d8a979

Browse files
committed
custom gateway option
1 parent 6603277 commit 0d8a979

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/Lighthouse/uploadEncrypted/decrypt/browser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { fetchWithTimeout } from '../../utils/util'
66
export default async (
77
cid: string,
88
fileEncryptionKey: string,
9-
mimeType: string
9+
mimeType: string,
10+
gatewayUrl?: string
1011
) => {
12+
const gateway = gatewayUrl || lighthouseConfig.lighthouseGateway
1113
const response = await fetchWithTimeout(
12-
lighthouseConfig.lighthouseGateway + '/api/v0/cat/' + cid,
14+
gateway + '/api/v0/cat/' + cid,
1315
{
1416
method: 'POST',
1517
timeout: 7200000,

src/Lighthouse/uploadEncrypted/decrypt/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import node from './node'
44
export default async (
55
cid: string | any,
66
fileEncryptionKey: string,
7-
mimeType = 'null'
7+
mimeType = 'null',
8+
gatewayUrl?: string
89
) => {
910
// Upload File to IPFS
1011
//@ts-ignore
1112
if (typeof window === 'undefined') {
12-
return await node(cid, fileEncryptionKey)
13+
return await node(cid, fileEncryptionKey, gatewayUrl)
1314
} else {
14-
return await browser(cid, fileEncryptionKey, mimeType)
15+
return await browser(cid, fileEncryptionKey, mimeType, gatewayUrl)
1516
}
1617
}

src/Lighthouse/uploadEncrypted/decrypt/node.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { decryptFile } from '../encryptionNode'
33
import { lighthouseConfig } from '../../../lighthouse.config'
44
import { fetchWithTimeout } from '../../utils/util'
55

6-
export default async (cid: string, fileEncryptionKey: any) => {
6+
export default async (cid: string, fileEncryptionKey: any, gatewayUrl?: string) => {
77
try {
8+
const gateway = gatewayUrl || lighthouseConfig.lighthouseGateway
89
const response = await fetchWithTimeout(
9-
lighthouseConfig.lighthouseGateway + '/api/v0/cat/' + cid,
10+
gateway + '/api/v0/cat/' + cid,
1011
{
1112
method: 'POST',
1213
timeout: 7200000,

0 commit comments

Comments
 (0)