Skip to content

Commit

Permalink
Buffer Transfer API
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhalevedant06 committed Dec 4, 2022
1 parent 1d20249 commit 3ae5cd1
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
151 changes: 151 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-lottie": "^1.2.3",
"react-pdf": "^6.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.4",
"react-scripts": "5.0.1",
Expand Down
37 changes: 37 additions & 0 deletions client/src/pages/book/Book.view.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState } from 'react';
import { Document, Page } from 'react-pdf';
import axios from '../../utils/axiosInstance';

const BookView = () => {
const [numPages, setNumPages] = useState(null);
const [pageNumber, setPageNumber] = useState(1);
const [file,setFile] = useState(null);

const getBook = async()=>{
const data = {
ipfsLink:"https://ipfs.moralis.io:2053/ipfs/Qmb7axp3nYTctZjpiLX1wkXdoaHXu7iNQAVZdQuJNoHXj5/uploads/sample.pdf"
}
const res = await axios.post('book/get',data)
// setFile(res.data)
setFile(res.data.buffer.data)
console.log(res)
}

function onDocumentLoadSuccess({ numPages }) {
setNumPages(numPages);
}
return (
<>
<Document file={""} onLoadSuccess={onDocumentLoadSuccess}>
<Page pageNumber={pageNumber} />
</Document>
<p>
Page {pageNumber} of {numPages}
</p>
<button onClick={()=>getBook()}>Load</button>

</>
)
}

export default BookView
Binary file added client/src/pages/book/sample.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions client/src/routes/routes.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default function Router() {
path: "books/:id",
element: <SingleBook />,
},
{
path:"bookView/:bookID",
element:<BookView/>
}
],
},
{
Expand Down Expand Up @@ -88,3 +92,7 @@ const VerifyOTP = Loadable(
const SingleBook = Loadable(
lazy(() => import("../pages/book/SingleBook.component"))
);

const BookView = Loadable(
lazy(() => import("../pages/book/Book.view"))
);
Loading

0 comments on commit 3ae5cd1

Please sign in to comment.