Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wiktorboro/drf-image-upload
https://github.com/wiktorboro/drf-image-upload
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/wiktorboro/drf-image-upload
- Owner: WiktorBoro
- Created: 2022-07-23T15:02:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-01T21:24:07.000Z (over 2 years ago)
- Last Synced: 2023-03-05T08:33:26.091Z (almost 2 years ago)
- Language: Python
- Size: 86.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Image upload based on django
# API capabilities
- Create Account Tier with the given parameters
- Create Users with given account tier
- Get users list
- Get account tiers list
- Upload image for the user
- Get a list of photos and sizes (available for the account level) for, a given user
- Generate expiring binary image (if your account level allows it)# Heroku deploy
https://image-upload2.herokuapp.com
# Quickstart
## Clone repository
`git clone https://github.com/WiktorBoro/rock-paper-scissors.git`## Install the libraries
`pip install -r requirements.txt`## Create superuser to access the database
`python manage.py createsuperuser`fill in the required fields
## Go to manage.py location
Run`python manage.py runserver`
### Start celery worker
for windows
`celery -A image_upload worker -l info --pool=solo`
and for macs
`celery -A image_upload worker -l info`
## Go to your local host
http://127.0.0.1:8000/## Admin site
http://127.0.0.1:8000/admin# Endpoints
## 1. Users
Url: `/users`
### Method: GET
Obtains a list of all existing users.
Return a list of dictionary with all users with their account levels
Return example:
```
[
{
"user_name":"",
"account_tier": ""
},
....
]`
```
### Method: POSTCreate new user
Body:
```
{
"user_name": "",
"account_tier": ""
}
```
Return dictionary with user_name and account tier keyReturn example:
```
{
"user_name": "Test",
"account_tier": "Basic"
}
```### Method: GET
Get a list of photos and sizes (available for the account level) for, a given userUrl: `/users/`
Return dictionary of dictionaries with the size of the images and a links to them
Return example:
```
[
{
"image_name": "",
"width": ,
"height": ,
"link": ,
"resize_images_list": [
{
"width": ,,
"height": ,
"resize_image": ""
},
....
]
},
....
]
```## 2. Account tiers
Url: `/account-tiers`
### Method: GET
Obtains a list of all existing account tiers with permissions and available image sizes.
Return a list of dictionary with all account tiers with permissions and available image
Return example:
```
[
{
"account_tier_name": "",
"link_to_the_originally_uploaded_file": ,
"ability_to_generate_expiring_links": ,
"image_height": ""
},
....
]
```### Method: GET
Url: `/account-tiers/`
Returns the data of one level of the account
Return example:
```
{
"account_tier_name": "",
"link_to_the_originally_uploaded_file": ,
"ability_to_generate_expiring_links": ,
"image_height": ""
}
```## 3. Image upload
Url: `/image-upload`
### Method: POST
Send a photo and give it a name for the chosen userBody:
```
{
"user": "",
"image_name": "",
"image":
}
```Return example:
```
{
"image_name": "",
"link": ,
"resize_images_list": [
{
"width": ,,
"height": ,
"resize_image": ""
},
....
]
}
```## 3. Generate expiring binary image
Url: `/expires-image`
### Method: POST
Specify the username, image name, and the expiration time, if you have sufficient account tier, the graphic will be generated which will expire after the specified time.
!Note the graphic must belong to the specified user
Body:
```
{
"user": "",
"original_image": "",
"image":
}
```Return example:
```
{
"expiring_time": ,
"resize_image": ""
}
```