Exemplo n.º 1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @CORS
  *
  * Generates thumbnails
  *
  * @see PreviewController::getThumbnails()
  *
  * @param string $ids the ID of the files of which we need thumbnail previews of
  * @param bool $square
  * @param double $scale
  *
  * @return array<string,array|string|null>
  */
 public function getThumbnails($ids, $square, $scale)
 {
     $idsArray = explode(';', $ids);
     foreach ($idsArray as $id) {
         // Casting to integer here instead of using array_map to extract IDs from the URL
         list($thumbnail, $status) = $this->getThumbnail((int) $id, $square, $scale);
         $thumbnail['fileid'] = $id;
         $thumbnail['status'] = $status;
         $this->eventSource->send('preview', $thumbnail);
     }
     $this->eventSource->close();
     $this->exitController();
 }
Exemplo n.º 2
0
 public function testEventSourceSend()
 {
     $thumbnailId = 1234;
     $file = $this->mockFile($thumbnailId);
     $preview = $this->mockBase64PreviewData($file);
     $event = 'preview';
     $message = 'event: ' . $event . PHP_EOL . 'data: ' . json_encode($preview) . PHP_EOL . PHP_EOL;
     $this->mockEventSourceSend($event, $preview, $message);
     $this->assertSame($message, $this->eventSource->send('preview', $preview));
 }