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,11 +1,10 @@
from pathlib import Path
from typing import BinaryIO
from uuid import uuid4
from aioshutil import copyfileobj
from fastapi import UploadFile
from barcodes.images_uploader.base import BaseImagesUploader
from barcodes.pdf import PDFGenerator
from constants import APP_PATH, API_ROOT
@@ -29,10 +28,10 @@ class BarcodeImagesUploader(BaseImagesUploader):
if file_location.exists():
file_location.unlink()
async def upload(self, upload_file: UploadFile) -> str:
filename = str(uuid4()) + '.' + upload_file.filename.split('.')[-1]
async def upload(self, file: BinaryIO, filename: str) -> str:
filename = str(uuid4()) + '.' + filename.split('.')[-1]
file_location = self.storage_path / filename
with open(file_location, 'wb') as buffer:
await copyfileobj(upload_file.file, buffer)
await copyfileobj(file, buffer)
return filename