Managing the helpers

Inside the client\app\services folder, create a file named helpers.global.ts and update it as follows:

// SNIPP SNIPPexport const HELPER = {getFileSize: function(bytes: number, decimals ? : number): string {             if (bytes == 0) return '0 Bytes';             var k = 1024,                     dm = decimals || 2,                     sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],                     i = Math.floor(Math.log(bytes) / Math.log(k));             return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];     }}// SNIPP SNIPP

As of now, we have one helper method, which converts bytes to human readable file sizes. Next, update client\app\services\global.constants.ts and add the following:

// SNIPP SNIPPexport const GLOBAL = {        // SNIPP allowedImageExt: ['jpg', 'jpeg', 'gif', ...

Get Google Cloud AI Services Quick Start Guide 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.