Gathering detailed insights and metrics for @dankom/react-file-previewer
Gathering detailed insights and metrics for @dankom/react-file-previewer
Gathering detailed insights and metrics for @dankom/react-file-previewer
Gathering detailed insights and metrics for @dankom/react-file-previewer
npm install @dankom/react-file-previewer
Typescript
Module System
Node Version
NPM Version
JavaScript (89.48%)
CSS (10.52%)
Total Downloads
1,199
Last Day
5
Last Week
14
Last Month
42
Last Year
377
28 Stars
100 Commits
19 Forks
4 Watching
38 Branches
5 Contributors
Latest Version
0.8.2
Package Id
@dankom/react-file-previewer@0.8.2
Unpacked Size
185.26 kB
Size
37.47 kB
File Count
33
NPM Version
7.19.0
Node Version
14.17.1
Cumulative downloads
Total Downloads
Last day
0%
5
Compared to previous day
Last week
55.6%
14
Compared to previous week
Last month
27.3%
42
Compared to previous month
Last year
55.8%
377
Compared to previous year
8
1
24
A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.
npm i react-file-previewer
This component supports URLs and base64 encoded data.
1import FilePreviewer from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewer file={{ 7 url: "https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf"}} 8 /> 9 </div> 10);
1import FilePreviewer from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewer 7 file={{ 8 data: "<base64 string>", 9 mimeType: 'application/pdf', 10 name: 'sample.pdf' // for download 11 }} 12 /> 13 </div> 14);
1import { useState } from 'react'; 2import FilePreviewer from 'react-file-previewer'; 3 4const PDF1_URL = 5 'https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf'; 6 7export const App = () => { 8 const [file, setFile] = useState({ url: PDF1_URL }); 9 10 const onFileChange = event => { 11 const fileReader = new window.FileReader(); 12 const file = event.target.files[0]; 13 14 fileReader.onload = fileLoad => { 15 const { result } = fileLoad.target; 16 setFile({ url: result }); 17 }; 18 19 fileReader.readAsDataURL(file); 20 }; 21 22 return ( 23 <div> 24 <h1>My App</h1> 25 <input type="file" onChange={onFileChange} /> 26 <FilePreviewer 27 file={file} 28 /> 29 </div> 30 ) 31};
This will render the first page of the file as a thumbnail. It takes the exact same props as the default export
FilePreviewer
.
1import {FilePreviewerThumbnail} from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewerThumbnail 7 file={{ 8 data: "<base64 string>", 9 mimeType: 'application/pdf', 10 name: 'sample.pdf' // for download 11 }} 12 /> 13 -or- 14 <FilePreviewerThumbnail file={{ 15 url: "https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf"}} 16 /> 17 </div> 18);
Prop name | Type | Description |
---|---|---|
file | object | Refer to file object |
onClick | function | Event handler for when viewer is clicked |
hideControls | bool | If 'true', viewer won't display the zoom, page up/down, and fit-to-screen controls |
Prop name | Type | Description |
---|---|---|
file | object | Refer to file object |
onClick | function | Event handler for when viewer is clicked |
hideControls | bool | If 'true', viewer won't display the zoom, page up/down, and fit-to-screen controls |
style | object | Any css style overrides |
Prop name | Type | Description |
---|---|---|
url | string | This can be used by itself with no other prop |
data | string | Base64 encoded string of file. If used, mimeType must also be provided |
mimeType | string | Type of the file |
name | string | Used to specify the filename when download button is clicked |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 9/14 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
29 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More