title: How can I deploy a Firebase Function that runs if a file is uploaded to Firebase Storage?
body: <p>I am trying to deploy a Firebase Function that runs if an image is uploaded to a bucket named "upload".  However, when I try to deploy the function I am getting this error:</p>
  
  <p><strong>Failed to configure trigger GCS Bucket: upload</strong></p>
  
  <p>Here is some additional information:</p>
  
  <p>My bucket is: gs://my-firestore-c379d.appspot.com/upload</p>
  
  <p>Here is a sample of the code:</p>
  
  <pre><code>'use strict';
  
  const functions = require('firebase-functions');
  const gcs = require('@google-cloud/storage')();
  
  functions.storage.bucket('upload').object().onChange(event =&gt; {
  
  exports.photoInfo = functions.storage.object().onChange(event =&gt; {
  const fileBucket = object.bucket; // The Storage bucket that contains the file.
  const filePath = object.name; // File path in the bucket.
  const contentType = object.contentType; // File content type.
  const resourceState = object.resourceState; // The resourceState is 'exists' or 'not_exists' (for file/folder deletions).
  const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.
  const metadata = object.metadata;
  const guestId = object.metadata['guestId'];
  
  console.log('object:' + object);
  console.log('fileBucket: ' + fileBucket);
  console.log('filePath: ' + filePath);
  console.log('contentType: ' + contentType);
  console.log('resourceState: ' + resourceState);
  console.log('metageneration: ' + metageneration);
  console.log('metadata: ' + metadata);
  console.log('guestId: ' + guestId);
  
  return 0;
  
  });
  </code></pre>
  
  <p>This is my package.json:</p>
  
  <pre><code>{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "./node_modules/.bin/eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
   },
  "dependencies": {
    "firebase-admin": "~5.8.1",
    "firebase-functions": "^0.8.1",
    "@google-cloud/storage": "^1.5.2"
  },
  "devDependencies": {
    "eslint": "^4.12.0",
    "eslint-plugin-promise": "^3.6.0"
  },
  "private": true
  }
  </code></pre>
  
  <p>I did some research and found these two links, but I am still not able to remove that error:</p>
  
  <p><a href="https://github.com/firebase/functions-samples/issues/66" rel="nofollow noreferrer">https://github.com/firebase/functions-samples/issues/66</a></p>
  
  <p><a href="https://github.com/firebase/friendlychat-web/issues/184#issuecomment-290914672" rel="nofollow noreferrer">https://github.com/firebase/friendlychat-web/issues/184#issuecomment-290914672</a></p>
  
  <p>How can create a function that only listens to changes made in the "upload" bucket and remove that error?</p>
  
  <p>Thanks for your help.</p>