Commit 56291917 authored by Jan Reimes's avatar Jan Reimes
Browse files

🔧 chore(adobe): remove unused StreamAsset import and refactor upload logic

parent 515c9a1f
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ from adobe.pdfservices.operation.exception.exceptions import (
    ServiceApiException,
    ServiceUsageException,
)
from adobe.pdfservices.operation.io.stream_asset import StreamAsset
from adobe.pdfservices.operation.pdf_services import PDFServices
from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
from adobe.pdfservices.operation.pdfjobs.jobs.create_pdf_job import CreatePDFJob
@@ -66,14 +65,15 @@ class AdobeProvider(AbstractProvider):
            credentials = ServicePrincipalCredentials(client_id=self.client_id, client_secret=self.client_secret)
            pdf_services = PDFServices(credentials=credentials)
            media_type = self._media_type_for_format(input_format)
            input_stream = StreamAsset(input_path.read_bytes(), mime_type=media_type.value)
            input_asset = pdf_services.upload(input_stream=input_stream)
            input_asset = pdf_services.upload(input_stream=input_path.read_bytes(), mime_type=media_type.value)

            job = CreatePDFJob(input_asset=input_asset)
            polling_url = pdf_services.submit(job)
            result = pdf_services.get_job_result(polling_url, CreatePDFJobResult)
            stream_asset = result.resource.stream_asset
            output_path.write_bytes(stream_asset.read())
            response = pdf_services.get_job_result(polling_url, CreatePDFJobResult)
            result = response.get_result()
            asset = result.get_asset()
            stream_asset = pdf_services.get_content(asset)
            output_path.write_bytes(stream_asset.get_input_stream())
        except ServiceUsageException as exc:
            raise QuotaExceededError("Adobe quota exceeded.") from exc
        except ServiceApiException as exc: