From d073bfba1e4d65b41dc04690f07126bd8b9c2028 Mon Sep 17 00:00:00 2001 From: TeodorusNathaniel Date: Wed, 16 Aug 2023 23:24:18 +0700 Subject: [PATCH] Change save file to use subsocial offchain --- src/server/ipfs.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/server/ipfs.ts b/src/server/ipfs.ts index bb660dd98..402d3f763 100644 --- a/src/server/ipfs.ts +++ b/src/server/ipfs.ts @@ -11,6 +11,7 @@ export function getIpfsApi() { const ipfs = new SubsocialIpfsApi({ ...CRUST_IPFS_CONFIG, headers, + offchainUrl: 'https://api.subsocial.network', }) ipfs.setWriteHeaders(headers) ipfs.setPinHeaders(headers) @@ -18,14 +19,16 @@ export function getIpfsApi() { return { ipfs, saveAndPinJson: async (content: Record) => { - const cid = await ipfs.saveJson(content) - await ipfs.pinContent(cid, { 'meta.gatewayId': 1 }) - return cid + const cid = await ipfs.saveContentToOffchain(content as any) + // const cid = await ipfs.saveJson(content) + // await ipfs.pinContent(cid, { 'meta.gatewayId': 1 }) + return cid?.toString() ?? '' }, saveAndPinImage: async (content: any) => { - const cid = await ipfs.saveFile(content) - await ipfs.pinContent(cid, { 'meta.gatewayId': 1 }) - return cid + const cid = await ipfs.saveContentToOffchain(content as any)! + // const cid = await ipfs.saveFile(content) + // await ipfs.pinContent(cid, { 'meta.gatewayId': 1 }) + return cid?.toString() ?? '' }, } }