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: ipfs storage provider #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 13 additions & 12 deletions front-end/src/utils/ipfsStorage.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { Web3Storage } from "web3.storage";
import { NFTStorage } from 'nft.storage';

const web3storage_key = "";
const token = '';

export const IPFS_GATEWAY = "https://ipfs.io/ipfs/";

function GetAccessToken() {
return web3storage_key;
}
export const IPFS_GATEWAY = "https://nftstorage.link/ipfs/"; //Gateway from nft.storage

function MakeStorageClient() {
return new Web3Storage({ token: GetAccessToken() });
return new NFTStorage({ token });
}


//const storage = new NFTStorage({ token })


export const saveContent = async (file) => {
console.log("Uploading files to IPFS with web3.storage....");
const client = MakeStorageClient();
const cid = await client.put([file]);
console.log("Stored files with cid:", cid);
console.log(`storing file(s)...with nft.storage`);
const storage = MakeStorageClient();
//
const cid = await storage.storeDirectory([file]);
console.log("Stored files with cid:", { cid });
return cid;
};