Skip to content

Preview files using QuickLook in react-native. Support for local files via base64 and downloadable files

Notifications You must be signed in to change notification settings

GeminidSystems/react-native-quicklook-view

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-quicklook-view

Supported Versions

react-native-select-attachment react-native
>= 0.0.1 0.60+

Description

react-native-quicklook-view allows you to preview images, documents, and other files through BASE64 or file paths, or a URL.

Getting Started

$ npm install react-native-select-attachment --save

Android

Not supported in the current release, check back for future releases or create a PR

iOS

CocoaPods on iOS needs this extra step

$ npx pod-install

Usage

To import into your react app, import the SelectAttachmentButton component.

import QuickLookView from 'react-native-quicklook-view';
Download Example
<QuickLookView
   style = {{
     alignItems: "center",
     justifyContent: "center",
   }}
   fileSource = "DOWNLOAD"
   url =  "https://www.weather.gov/media/wrn/MP4/2017DetermineYouRisk.mp4"
   fileID = {1}
 />
Base64 Example
<QuickLookView
   style = {{
     alignItems: "center",
     justifyContent: "center",
   }}
   fileSource = "BASE64"
   fileType = "png"
   fileData =  "iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAABDlBMVEX////+52H+rjQ/KDJ0Pzn/7mP+qjD5qzQlFTLU0tMsBho9JS9JNj53ZD7a2NkrAhk5IDH+4V1dTlT0pzT/sjQjEzJ/a0AxEiFUQ0rPy82Gc0H+414pBi7g3t4lAC7542A2GydOLjTq01tvWzxmWV6OekPDv8A1HDCVgUWOholuPDhnKjbknDRvY2h3bHGHfYH+zE0sGjLIiDMtEC/OuVSjnJ+8p08yFzCwq62wm0yjj0j+1lTfmDTUkDP+0FD+wUS2fDOXb0PfyVgDADIAACodAABSQ1U8LkAaACjQu1AhABuzqZSahj9dVWEFAAAkABFBFx8NABOVh2saABgpACKJel5jUDk5Iz1cT2APACMHNASgAAAFgklEQVR4nO3de1faSBzG8YqLeL8gXiHI4t1VLNaKF1K7YhXBrqu9ue//jSwzE2xihmRywZkJz/ec/ulhPieZ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HGp8e7NKcQB094TDRifUbJxoR7kzn7EPhw9RAKnp7dDRjXc2YghFAD4bZ7FDgraiA0PPox5df6XTRa/mKOJDAmwgtnxnuPgjJvFEQcDK8PnuiYCC+c6L3XCtynhMSa+OkJIYQDIOSOAvWE3QeuBRfOrnP62Q9hfs6e1xuenGXoM/P2zeAPzWPC4lAfRgG39yOOhI/ePr2oWHgOQHMK1/qh4SU+3F8J2QbMQgghhNKEuf0FOiaUFIadD1YvY2KDFOLZqv0Xhp0PVvuN0U4LX4PT3lAYFOUUVukG3IAQwkQLSU1lhd0xEV6Ypd2UWfGYHPMhH1aYmaeZz3SFkR/B/atInlB7Hc+hvIw2H6zqdEw0D6LSrCbj3I4Rd15XyDYghBAOkpBUUEiYq4/SMRGXMLtMui2v2RPA5HldRpsPVuYNXVPkMeHstlD83bXAeHw1GKLNB5POB6tmzDSrZfv9YZE7wpf+6w4grNpevQQhhIMrtCXyd4s4hTmzanv1Pgmzk7Z+vZodnLkQWZixlTJv7S/fH6Gz56Z9dtRjnAvdo3bkmA9v/0xYx7tNqvWIh4srdOw8CCGEkCMs2f737pPQPh8kHcPuv/4dw+4rSBA6qzQXXDWOcqKYzw33jzdlf87cWYXzpvWqKS7cdv94CcK3DUIIq8oLD2aWXLXMnGifW+4ff1BLyG2XM0K4/Xcqe6kh433uidsShKoGIYTqp6Lwf8KYrqB65WRiAAAAAElFTkSuQmCC"
   fileID = {1}
 />

Reference

Properties

fileID

A unique identifier for the file

Type Required Default
String Yes None

fileSource

The source of the file. Valid values include:

  • DOWNLOAD
  • BASE64
Type Required Default
[String] Yes None

url

The URL of the file. This is used only is fileSource is set to DOWNLOAD

Type Required Default
String No None

fileData

Base64 encoded String of the file data. This is used only if fileSource is set to BASE64

Type Required Default
String No None

fileType

The file type for Base64 encoded string. Example "png" or "pdf"

Type Required Default
String No false

width

The width of the QuickLook view

Type Required Default
Integer No Dimensions.get('window').width

height

The height of the QuickLook view

Type Required Default
Integer No Dimensions.get('window').height