Skip to content

Commit

Permalink
Merge pull request #343 from dappforce/deploy/ipfs
Browse files Browse the repository at this point in the history
Change save file to use subsocial offchain
  • Loading branch information
olehmell authored Aug 16, 2023
2 parents 5bcf758 + d073bfb commit 18a3121
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/server/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ export function getIpfsApi() {
const ipfs = new SubsocialIpfsApi({
...CRUST_IPFS_CONFIG,
headers,
offchainUrl: 'https://api.subsocial.network',
})
ipfs.setWriteHeaders(headers)
ipfs.setPinHeaders(headers)

return {
ipfs,
saveAndPinJson: async (content: Record<any, any>) => {
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() ?? ''
},
}
}

0 comments on commit 18a3121

Please sign in to comment.