3.0.0 • Published 6 months ago

react-capacitor-firebase-image-upload v3.0.0

Weekly downloads
30
License
Apache-2.0
Repository
github
Last release
6 months ago

React + Capacitor + Firebase Image Upload

An image upload UI built for react/capacitor utilizing firebase storage.

Demo

Features:

  • Automatically adds image width & height in firebase storage customMetadata field.

Install

yarn add react-capacitor-firebase-image-upload

Quick Usage

App.tsx (Or other high level component)

import { ImageUploadContextProvider, ImageUploadContext } from 'react-capacitor-firebase-image-upload';

import * as firebase from 'firebase/app';
import 'firebase/storage';

const fire = firebase.initializeApp({
  ... firebase key stuff here ...
});

const storage = firebase.storage().ref();

...

const App: React.FC = () => {
  const { open } = useContext(ImageUploadContext);
  return (
    <App>
        <ImageUploadContextProvider firebaseStorageRef={storage}>
            {/* <Routes & Other App Stuff> */}
            <button onClick={() => open(console.log, console.error)}>
        </ImageUploadContextProvider>
    </App>
  );
};

ImageUploadContextProviderProps

KeyTypeRequiredDefaultDescription
buttonColorstringNo"#222"Color of the primary buttons
acceptedFileTypesstring[]No'image/png', 'image/jpeg', 'image/bmp'String array of accepted file types
firebaseStorageReffirebase.storage.ReferenceYesundefinedThe reference object to your firebase storage

ImageUploadContext

KeyTypeDescription
isOpenbooleanState of the image upload overlay
open(successOrCancelFunction?: (result: ImageUploadSuccessundefined) => void, errorCallback: (err:Error) => void, opts?: ImageUploadOptions) => void;Function to call when you want to open the image upload overlay
close() => void;Function to call when you want the overlay to close

ImageUploadOptions

KeyTypeDescription
pathPrefixstringPrefix for the storage location (ex: "user_avatars/" would upload images to a user_avatars folder)

Feature wishlist:

  • Cropping
  • Capacitor native camera/camera roll
3.0.0

6 months ago

2.3.0

1 year ago

2.2.0

2 years ago

2.1.4

2 years ago

2.1.2

2 years ago

2.1.3

2 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.2

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago