Attachments

Once you have created a case, it is possible to attach files to it.

To add a new attachment, create an UploadedFile using the file post data of the request and set it on the Attachment object:

<?php

/** @var \Jadu\Quantum\ServiceApiClient\Manager\AttachmentManager $attachmentManager */
$attachmentManager = $container->get('quantum_service_api_client.manager.attachment');

$file = new UploadedFile($tmpFile, basename($tmpFile), 'image/png');

$attachment = new Attachment();
$attachment->setCaseHeader($case);
$attachment->setName($file->getName());
$attachment->setDescription('the description of the file');
$attachment->setFile($file);

$attachmentManager->save($attachment);

Once saved successfully, the $attachment object will be hydrated with the returned data, including a download url, the uploader (User) and an id.

The Attachment::$file property is not rehydrated after saving and should only be used when uploading a new file.

results matching ""

    No results matching ""