Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change save file to use subsocial offchain #343

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() ?? ''
},
}
}
Loading