Upload Files

You can upload File or Blob types, a Uint8Array or base64 encoded strings to upload files to Cloud Storage. For our example, we will use File type. As mentioned earlier, first we need to get a reference to the full path of the file, including the filename.

We will modify the AddTicketForm.jsx file to allow the user to upload a screenshot or an image related to the ticket.

The src/add-ticket/'AddTicketForm.jsx' file now looks like the following. The changes are highlighted in bold with comments:

import React, { Component } from 'react';import firebase from '../firebase/firebase-config';import { ToastSuccess, ToastDanger } from 'react-toastr-basic';class AddTicketForm extends Component {  constructor(props) {    super(props); this.handleSubmitEvent ...

Get Serverless Web Applications with React and Firebase now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.