temp images on products
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import Annotated, Union
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, UploadFile
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
import utils.dependecies
|
||||
@@ -15,7 +15,7 @@ from services.product import ProductService
|
||||
product_router = APIRouter(
|
||||
prefix="/product",
|
||||
tags=["product"],
|
||||
dependencies=[Depends(get_current_user)]
|
||||
# dependencies=[Depends(get_current_user)]
|
||||
)
|
||||
|
||||
|
||||
@@ -125,3 +125,18 @@ async def get_product_barcode(
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await BarcodeService(session).get_barcode(request)
|
||||
|
||||
|
||||
@product_router.post(
|
||||
'/images/upload/{product_id}',
|
||||
response_model=ProductUploadImageResponse,
|
||||
operation_id='upload_product_image'
|
||||
)
|
||||
async def upload_product_image(
|
||||
product_id: int,
|
||||
upload_file: UploadFile,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
|
||||
):
|
||||
file_bytes = upload_file.file.read()
|
||||
return await ProductService(session).upload_image(product_id, file_bytes)
|
||||
|
||||
Reference in New Issue
Block a user