See Release Notes
Long Term Support Release
Differences Between: [Versions 311 and 401] [Versions 400 and 401]
1 <?php 2 3 namespace MongoDB\GridFS\Exception; 4 5 use MongoDB\Exception\RuntimeException; 6 7 use function MongoDB\BSON\fromPHP; 8 use function MongoDB\BSON\toJSON; 9 use function sprintf; 10 use function stream_get_meta_data; 11 12 class StreamException extends RuntimeException 13 { 14 /** 15 * @param resource $source 16 * @param resource $destination 17 */ 18 public static function downloadFromFilenameFailed(string $filename, $source, $destination): self 19 { 20 $sourceMetadata = stream_get_meta_data($source); 21 $destinationMetadata = stream_get_meta_data($destination); 22 23 return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $filename)); 24 } 25 26 /** 27 * @param mixed $id 28 * @param resource $source 29 * @param resource $destination 30 */ 31 public static function downloadFromIdFailed($id, $source, $destination): self 32 { 33 $idString = toJSON(fromPHP(['_id' => $id])); 34 $sourceMetadata = stream_get_meta_data($source); 35 $destinationMetadata = stream_get_meta_data($destination); 36 37 return new static(sprintf('Downloading file from "%s" to "%s" failed. GridFS identifier: "%s"', $sourceMetadata['uri'], $destinationMetadata['uri'], $idString)); 38 } 39 40 /** @param resource $source */ 41 public static function uploadFailed(string $filename, $source, string $destinationUri): self 42 { 43 $sourceMetadata = stream_get_meta_data($source); 44 45 return new static(sprintf('Uploading file from "%s" to "%s" failed. GridFS filename: "%s"', $sourceMetadata['uri'], $destinationUri, $filename)); 46 } 47 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body