Skip to content

Commit

Permalink
reset commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dnouv committed Apr 25, 2022
1 parent df318b4 commit d99db43
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# misc
.DS_Store
*.pem
package-lock.json

# debug
npm-debug.log*
Expand Down
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"emoji-toolkit": "^6.6.0",
"firebase": "^9.6.3",
"firebase-admin": "^10.0.2",
"ipfs-core": "^0.14.2",
"js-cookie": "^3.0.1",
"marked": "^4.0.12",
"next": "12.0.7",
Expand Down
49 changes: 49 additions & 0 deletions app/pages/ipfs/ipfsDemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Head from "next/head";
import { Button, Stack } from "react-bootstrap";
import * as IPFS from 'ipfs-core'
import { useState } from "react";


function IPFSdemo() {

const [fileUrl, updateFileUrl] = useState(``)

const getIPFS = async (e) => {
const file = e.target.files[0]

const ipfs = await IPFS.create()

console.log("ipfs", ipfs)
const { cid } = await ipfs.add(file)
const url = `https://ipfs.io/ipfs/${cid.toString()}`
updateFileUrl(cid.toString())
// const { cid } = await ipfs.add('Hello world')

console.info(cid.toString())
await ipfs.stop()

}

return (
<div>
<Head>
<title>Form</title>
<meta name="description" content="Rocket.Chat form tool demo" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<Stack className="mx-auto">
<h1 className="mx-auto mt-3">Preview of Form Component</h1>
</Stack>
<Button onClick={getIPFS}>IPFS</Button>
<input
type="file"
onChange={getIPFS}
/>
{fileUrl && <div>The CID: {fileUrl}</div>}

</div>
);
}

export default IPFSdemo;
Binary file added app/pages/ipfs/rc_show_badge_Moment.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d99db43

Please sign in to comment.