fix: uploading barcode pdf files instead of images
This commit is contained in:
		@@ -30,21 +30,9 @@ class BarcodeImagesUploader(BaseImagesUploader):
 | 
			
		||||
            file_location.unlink()
 | 
			
		||||
 | 
			
		||||
    async def upload(self, upload_file: UploadFile) -> str:
 | 
			
		||||
        # Create temp file in filesystem
 | 
			
		||||
        temp_filename = str(uuid4()) + '.' + upload_file.filename.split('.')[-1]
 | 
			
		||||
        temp_file_location = self.storage_path / temp_filename
 | 
			
		||||
        with open(temp_file_location, 'wb') as buffer:
 | 
			
		||||
        filename = str(uuid4()) + '.' + upload_file.filename.split('.')[-1]
 | 
			
		||||
        file_location = self.storage_path / filename
 | 
			
		||||
        with open(file_location, 'wb') as buffer:
 | 
			
		||||
            await copyfileobj(upload_file.file, buffer)
 | 
			
		||||
 | 
			
		||||
        # Generate PDF file and save it
 | 
			
		||||
        res_filename = str(uuid4()) + '.pdf'
 | 
			
		||||
        res_file_location = f"{self.storage_path}/{res_filename}"
 | 
			
		||||
        temp_file_url = f"{self.relative_path}/{temp_filename}"
 | 
			
		||||
 | 
			
		||||
        pdf_gen = PDFGenerator()
 | 
			
		||||
        pdf_gen.generate_barcode_image(temp_file_url, res_file_location)
 | 
			
		||||
 | 
			
		||||
        # Remove temp file
 | 
			
		||||
        self.delete(temp_filename)
 | 
			
		||||
 | 
			
		||||
        return res_filename
 | 
			
		||||
        return filename
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user