#!/usr/bin/env php $case->value)), PHP_EOL )); } if($isHash) { $fileId = match(strlen($fileId)) { 32 => $fileId, 43 => UriBase64::decode($fileId), 64 => hex2bin($fileId), 66 => hex2bin(substr($fileId, 2)), default => null, }; $fileField = StorageRecordGetFileField::Hash; } else { if($isBase62) $fileId = XNumber::fromBase62($fileId); if($isUploadId) { $uploadId = $fileId; $fileId = null; try { $variantInfo = $eeprom->uploadsCtx->uploads->getUploadVariant($uploadId, ''); } catch(RuntimeException $ex) { $hint = $isBase62 ? 'trim last four characters from base62 id' : 'specify -s for base62 ids'; die(sprintf('The requested upload does not exist. (hint: %s)%s', $hint, PHP_EOL)); } $fileId = $variantInfo->fileId; } } if($fileId === null) die(sprintf('Could not resolve file ID from the provided inputs.%s', PHP_EOL)); try { $storageInfo = $eeprom->storageCtx->records->getFile($fileId, $fileField); } catch(RuntimeException $ex) { $hint = $isUploadId ? ( $isBase62 ? 'trim last four characters from base62 id' : 'specify -s for base62 ids' ) : 'specify -h for hashes or -u to use upload ids'; die(sprintf('The requested file does not exist. (hint: %s)%s', $hint, PHP_EOL)); } printf( 'Found file #%d of %d bytes with type %s at %s with SHA256 hash %s.%s', $storageInfo->id, $storageInfo->size, htmlspecialchars($storageInfo->type), $storageInfo->createdAt->toIso8601ZuluString(), UriBase64::encode($storageInfo->hash), PHP_EOL ); try { printf('Attempting to deny file...%s', PHP_EOL); $eeprom->denylistCtx->denyFile($storageInfo, $reason); } catch(Exception $ex) { printf('Exception occurred while deleting file:%s', PHP_EOL); printf('%s%s', $ex->getMessage(), PHP_EOL); }