/** * @param $attachmentFile ReservationAttachment * @return int */ public function AddReservationAttachment(ReservationAttachment $attachmentFile) { $command = new AddReservationAttachmentCommand($attachmentFile->FileName(), $attachmentFile->FileType(), $attachmentFile->FileSize(), $attachmentFile->FileExtension(), $attachmentFile->SeriesId()); $id = ServiceLocator::GetDatabase()->ExecuteInsert($command); $extension = $attachmentFile->FileExtension(); $attachmentFile->WithFileId($id); $fileSystem = ServiceLocator::GetFileSystem(); $fileSystem->Add($fileSystem->GetReservationAttachmentsPath(), "{$id}.{$extension}", $attachmentFile->FileContents()); return $id; }
/** * @param ReservationAttachment $attachment * @return void */ public function BindAttachment(ReservationAttachment $attachment) { header('Content-Type: ' . $attachment->FileType()); header('Content-Disposition: attachment; filename="' . $attachment->FileName() . '"'); ob_clean(); flush(); echo $attachment->FileContents(); }