chphoom / aroundtheblock

0 stars 1 forks source link

upload part 2... #135

Open chphoom opened 1 year ago

chphoom commented 1 year ago

this from ChatGPT:

Yes, you can use the Imgur API to handle file uploads in your web application and store the generated Imgur links. Imgur is a popular image hosting and sharing platform that provides a simple and easy-to-use API for developers.

To use the Imgur API, you will need to first create an account on the Imgur website and obtain an API key. Once you have your API key, you can use it to authenticate requests to the Imgur API and upload files using the API's image upload endpoint.

When you upload an image to the Imgur API, you will receive a link to the uploaded image, which you can then store in your PostgreSQL database. You can use this link to display the image in your Angular frontend.

Here's an example of how you can use the Imgur API to upload an image:

import requests

url = "https://api.imgur.com/3/upload"

headers = {
    "Authorization": "Client-ID YOUR_CLIENT_ID"
}

data = {
    "image": "IMAGE_DATA"
}

response = requests.post(url, headers=headers, data=data)

if response.status_code == 200:
    link = response.json()["data"]["link"]
    # Store the link in your PostgreSQL database
else:
    # Handle error

In this example, YOUR_CLIENT_ID should be replaced with your Imgur API client ID, and IMAGE_DATA should be replaced with the actual image data you want to upload. Once you have the Imgur link, you can store it in your PostgreSQL database and use it to display the image in your Angular frontend.

chphoom commented 1 year ago

https://www.labnol.org/code/20526-javascript-image-uploader

chphoom commented 1 year ago

https://apidocs.imgur.com/#2078c7e0-c2b8-4bc8-a646-6e544b087d0f

https://github.com/Imgur/imgurpython