File tree Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Expand file tree Collapse file tree 1 file changed +8
-16
lines changed Original file line number Diff line number Diff line change 1
1
import { NFTStorage , Blob } from "nft.storage" ;
2
2
const ipfsGateway = "https://w3s.link/ipfs" ;
3
3
export const IPFSUriToUrl = ( uri : string ) => {
4
- return `${ ipfsGateway } /${ uri . split ( "ipfs://" ) . pop ( ) } ` ;
4
+ return `${ ipfsGateway } /${ uri . split ( "ipfs://" ) . pop ( ) } ` ;
5
5
} ;
6
6
const client = new NFTStorage ( {
7
- token : process . env . NEXT_PUBLIC_NFTSTORAGE_KEY || "" ,
7
+ token : process . env . NEXT_PUBLIC_NFTSTORAGE_KEY || "" ,
8
8
} ) ;
9
- console . log ( "TRIET" ) ;
10
- console . log ( process . env ) ;
11
- const objectToFile = ( obj : object , filename : string ) => {
12
- const blob = new Blob ( [ JSON . stringify ( obj ) ] , { type : "application/json" } ) ;
13
- return new File ( [ blob ] , filename ) ;
14
- } ;
15
- const stringToFile = ( str : string , filename : string ) => {
16
- return new File ( [ Buffer . from ( str ) ] , filename ) ;
17
- } ;
9
+
18
10
export const preparePutToIPFS = async ( data : string | object , filename ?: string ) => {
19
- const d = new Blob ( [ JSON . stringify ( data ) ] ) ;
20
- const put = async ( ) => {
21
- return await client . storeBlob ( d ) ;
22
- } ;
23
- return { put } ;
11
+ const d = new Blob ( [ JSON . stringify ( data ) ] ) ;
12
+ const put = async ( ) => {
13
+ return await client . storeBlob ( d ) ;
14
+ } ;
15
+ return { put } ;
24
16
} ;
You can’t perform that action at this time.
0 commit comments