Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const predictionClient = new automl.PredictionServiceClient();
// Firebase libraries
const functions = require('firebase-functions');
const admin = require('firebase-admin');

const db = admin.firestore();
admin.initializeApp(functions.config().firebase);

function resizeImg(filepath) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -68,7 +68,7 @@ function callAutoMLAPI(b64img) {
reject(err);
});
});

}

exports.callCustomModel = functions.storage.object().onFinalize(event => {
Expand All @@ -81,12 +81,12 @@ exports.callCustomModel = functions.storage.object().onFinalize(event => {
return resizeImg(destination);
} else {
return destination;
}
}
})
.then(() => {
let bitmap = fs.readFileSync(destination);
let data = new Buffer(bitmap).toString('base64');
return callAutoMLAPI(data);
return callAutoMLAPI(data);
})
.then((response) => {
let predictions = {};
Expand Down Expand Up @@ -115,4 +115,4 @@ exports.callCustomModel = functions.storage.object().onFinalize(event => {
.catch((err) => {
console.log('error occurred', err);
});
});
});