O
O
Oleg2020-09-02 14:48:41
Angular
Oleg, 2020-09-02 14:48:41

How to upload an image to the server by its URL in Angular?

Good afternoon!
There is a working service method for uploading a file to the server:

logoUpload(uploadData) {
        const url = this.apiHost+'client/logo-upload';
        return this.http.post<LogoUploadResponse>(url, uploadData).pipe(
            tap((newLogo: LogoUploadResponse) => this.log(`uploaded logo`)),
            catchError(this.handleError<LogoUploadResponse>('logoUpload'))
        );
    }


Everything works fine, but there is a need for an alternative way to send a file - by its URL.
There is some URL to the image (which is taken from another request). You need to upload this image via a POST request to the server (like the first one). You can’t just save it with your hands and then load it - you need to reduce the actions to one click.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question