Socket
Socket
Sign inDemoInstall

react-file-previewer

Package Overview
Dependencies
7
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-file-previewer

A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.


Version published
Weekly downloads
1.3K
decreased by-28.84%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-file-previewer

A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.

Installation

npm i react-file-previewer

Usage

This component supports URLs and base64 encoded data.

Basic Usage

import ReactFilePreviewer from 'react-file-previewer';

export const App = () => (
    <div>
        <h1>My App</h1>
        <ReactFilePreviewer file={{url: "https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf"}}/>
    </div>
);

Base64 Usage

import ReactFilePreviewer from 'react-file-previewer';

export const App = () => (
    <div>
        <h1>My App</h1>
        <ReactFilePreviewer 
            file={{
                data: "<base64 string>",
                mimeType: 'application/pdf',
                name: 'sample.pdf' // for download
            }}
        />
    </div>
);

Props

Prop nameTypeDescription
fileobjectHas properties: url, data, mimeType, name. Url can be used by itself. If base64 file, both data and mimeType must be provided. name is simply for a filename on download.
onClickfunctionEvent handler for when viewer is clicked
thumbnailboolIf 'true', viewer won't display the controls and will fill to size for display as a thumbnail
heightstringHeight of the viewer passed to the css styles
widthstringWidth of the viewer passed to the css styles

Keywords

FAQs

Last updated on 17 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc