I am pulling files from 3rd party server using apis and generating pdf files.

My code is some thing like this. I Will update the sample code to explain my approach.

foreach ($fileData['dataDocuments']['items'] as $document) {
    //API Call
    $urlToGetData = $this->api->getDocumentById($identifier, $docId);
    $data = $this->api->getDataFromApi($urlToGetData);
    $decodeData = json_decode($data, true);
    $labelContent[] = base64_decode((string)$imageString, true); //you can add more image strings.

    //use Magento\Shipping\Model\Shipping\LabelGenerator;
    $outputPdf = $this->labelGenarator->combineLabelsPdf($labelContent);

     }catch(\Exception $e){

While running through the loop ( I have pulling like 6 files from server using api) only first two files are generating and getting an error on $this->fileFactory->create()

I am not getting any exception also, Any hint to generate all files together here. If i run this for each and every file individually i can generate 6 files without no any issue. But my requirement is download all files at once. Any guess or suggestion to fix this issue highly appreciated.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.