Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
<?php

namespace MongoDB\GridFS\Exception;

use MongoDB\Exception\RuntimeException;
>
use function MongoDB\BSON\fromPHP; use function MongoDB\BSON\toJSON; use function sprintf; use function stream_get_meta_data; class StreamException extends RuntimeException { /** * @param resource $source * @param resource $destination */ public static function downloadFromFilenameFailed(string $filename, $source, $destination) : self { $sourceMetadata = stream_get_meta_data($source); $destinationMetadata = stream_get_meta_data($destination); return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $filename)); } /** * @param mixed $id * @param resource $source * @param resource $destination */ public static function downloadFromIdFailed($id, $source, $destination) : self { $idString = toJSON(fromPHP(['_id' => $id])); $sourceMetadata = stream_get_meta_data($source); $destinationMetadata = stream_get_meta_data($destination); return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS identifier: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $idString)); } /** @param resource $source */ public static function uploadFailed(string $filename, $source, string $destinationUri) : self { $sourceMetadata = stream_get_meta_data($source); return new static(sprintf('Uploading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationUri, $filename)); } }