spee.ch/image.php
Jeremy Kauffman 5c38fb0b21 Merge pull request #5 from stoatally/feature-content-type
Filter on and output the correct content type
2017-03-29 20:41:51 -04:00

38 lines
1.1 KiB
PHP

<?php
if (!defined('ROOT_PAGE')) { die('not allowed'); }
$claim = LBRY::findTopPublicFreeClaim($name);
if ($claim)
{
$getResult = LBRY::api('get', ['name' => $name, 'claim_id' => $claim['claim_id']]);
if (isset($getResult['completed']) && $getResult['completed'] && isset($getResult['download_path']))
{
$path = $getResult['download_path'];
header('Content-type: ' . $getResult['metadata']['content_type']);
header('Content-length: ' . filesize($path));
readfile($getResult['download_path']);
}
elseif (isset($getResult['written_bytes']))
{
echo 'This image is on it\'s way...<br/>';
echo 'Received: ' . $getResult['written_bytes'] . " / " . $getResult['total_bytes'] . ' bytes';
}
else
{
echo 'There seems to be a valid claim, but are having trouble retrieving the content.';
}
}
elseif (isset($_GET['new']) && $_GET['new'])
{
echo 'Your image is on the way. It can take a few minutes to reach the blockchain and be public. You can refresh this page to check the progress.';
}
else
{
echo 'No valid claim for this name. Make one!';
include './publish.php';
}
exit(0);