-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from kleros/fix/ipfs-migration
Fix/ipfs migration
- Loading branch information
Showing
4 changed files
with
24 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
PNK_DROP_JSON_RPC_URL='<string>' | ||
PNK_DROP_JSON_RPC_URL='<string>' | ||
FILEBASE_TOKEN='<BUCKET_TOKEN>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import path from "path"; | ||
import fs from "fs"; | ||
import dotenv from "dotenv"; | ||
|
||
import { File, FilebaseClient } from "@filebase/client"; | ||
dotenv.config(); | ||
|
||
// The API-TOKEN defines in which bucket is going to be stored | ||
const filebase = new FilebaseClient({ token: process.env.FILEBASE_TOKEN ?? "" }); | ||
|
||
export const fileToIpfs = async (filePath) => { | ||
const content = await fs.promises.readFile(filePath); | ||
const mimeType = 'application/json'; | ||
const fileName = path.basename(filePath); | ||
const cid = await filebase.storeDirectory([new File([content], `${fileName}`, { type: mimeType })]); | ||
return cid; | ||
}; |