feat: product barcode pdf resize

This commit is contained in:
2025-01-19 17:37:13 +04:00
parent b8947ce68e
commit defe31b55e
5 changed files with 52 additions and 36 deletions

View File

@@ -1,3 +1,4 @@
from io import BytesIO
from typing import Optional
from fastapi import HTTPException, UploadFile
@@ -278,12 +279,13 @@ class ProductService(BaseService):
async def upload_barcode_image(self, product_id: int, upload_file: UploadFile) -> ProductUploadBarcodeImageResponse:
try:
PdfMaker.check_is_correct_aspects_ratio(upload_file.file)
await self.get_model_by_id(product_id)
uploader = BarcodeImagesUploader()
await self.delete_model_barcode_image(uploader, product_id)
filename = await uploader.upload(upload_file)
file = PdfMaker.resize_pdf_with_reportlab(BytesIO(upload_file.file.read()))
filename = await uploader.upload(file, upload_file.filename)
barcode_image_url = uploader.get_url(filename)
product_barcode_image = ProductBarcodeImage(