Vivek Singh Bisht
Vivek Singh Bisht

Reputation: 67

How do I upload images to images to imgur in an angular application?

I currently am developing front-end of a blogging website in which a user is allowed to add feature image for the blog and the feature image is stored in cloud storage. I'm trying to use Imgur as the cloud storage for the feature images here.

I've never used cloud storage to store images of my website. So what is the suggested way to upload images in Imgur using Angular.

Also, I've read the docs and created a application in Imgur so I've got the client-id and client-secret for the application. I've authenticated my application in POSTMAN but I'm not understanding how to authenticate and authorise my application to access Imgur inside Angular.

Upvotes: 0

Views: 1327

Answers (2)

Vivek Singh Bisht
Vivek Singh Bisht

Reputation: 67

The reason why I was getting 400 error while trying to access the Imgur API in angular application was I was trying to access https://api.imgur.com/3/upload url. This URL for some reason is working just in POSTMAN. For accessing the Imgur API in your application use this url: https://api.imgur.com/3/image

Upvotes: 0

SELA
SELA

Reputation: 6803

According to the Imgur API it has a REST API which you can communicate with. In other words you can use HTTP request to upload the image from your angular application. In order to Imgur API to accept data from your application you need to specify the client-Id in the HTTP request headers.

Sample implementation of that API call will look something like this:

let headers = new Headers({'authorization': 'Client-ID clientid'});
this.http.post('https://api.imgur.com/3/upload', photo, {headers: headers})

Please find the Imgur Official API doumentation here

You can find another reference on how to upload image using Imgur API here

Upvotes: 1

Related Questions