Skip to content

Commit

Permalink
feat: it works, assets are served
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Oct 12, 2024
1 parent 363811f commit 3de99d5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions EMS/common-bundle/src/Storage/StorageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ public function getStreamFromArchive(string $hash, string $path): StreamWrapper
switch ($mimeType) {
case MimeTypes::APPLICATION_ZIP->value:
return $this->getStreamFromZipArchive($hash, $path, $archiveFile);
case MimeTypes::APPLICATION_JSON->value:
return $this->getStreamFromJsonArchive($hash, $path, $archiveFile);
}
throw new \RuntimeException(\sprintf('Archive format %s not supported', $mimeType));
}
Expand Down Expand Up @@ -578,4 +580,14 @@ private function getStreamFromZipArchive(string $hash, string $path, TempFile $z

return new StreamWrapper($file->getStream(), $mimeTypeHelper->guessMimeType($filename), $file->getSize());
}

private function getStreamFromJsonArchive(string $hash, string $path, TempFile $archiveFile): StreamWrapper
{
$file = Archive::fromStructure($archiveFile->getContents(), $this->hashAlgo)->getByPath($path);
if (null === $file) {
throw new NotFoundHttpException(\sprintf('File %s not found in archive %s', $path, $hash));
}

return new StreamWrapper($this->getStream($file->getHash()), $file->getType(), $file->getSize());
}
}

0 comments on commit 3de99d5

Please sign in to comment.