Function should be returning a promise of a string but doesn't

Function should be returning a promise of a string but doesn't

I'm trying to upload an image and return it's id with the following code:

I'm trying to upload an image and return it's id with the following code:

export function uploadImage(file: any, location: string, next: any): Promise<string> {
    try {
        if (!file) {
            throw new Error("No Image file");
        }
        const id = location + "/" + utilities.generatePushID();
        const options = {
            resource_type: "raw",
            public_id: id,
        };
        return cloudinary.uploader.upload_stream(options, (error: any, result: any) => {
            if (error) {
                 throw new Error("Couldn't upload");
             }
             return result.public_id;
        }).end(file.buffer);
    } catch (err) {
         return next(InternalError(err));
    }
}

However, whenever I try to call the function, it gives me back an UploadStream object rather than the string that I want. It's as if it immediately returns the uploader, rather than the result of the uploader. Why?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Deno vs Node.js: Deno Will Replace Node.JS?

Deno vs Node.js: Deno Will Replace Node.JS? What’s Deno, and how is it different from Node.js? Node.js is Dead – Long live Deno! The goal of Deno is not to replace Node.js, but to offer an alternative.

Node.js for Beginners - Learn Node.js from Scratch (Step by Step)

Node.js for Beginners - Learn Node.js from Scratch (Step by Step) - Learn the basics of Node.js. This Node.js tutorial will guide you step by step so that you will learn basics and theory of every part. Learn to use Node.js like a professional. You’ll learn: Basic Of Node, Modules, NPM In Node, Event, Email, Uploading File, Advance Of Node.