Skip to content

Warning: rewind(): stream does not support seeking #317

@acid24

Description

@acid24

PHP version used: 7.1.0

mongo-php-library version: 1.1.0

Hello,

Using this code

/*
Uses MongoDb\GridFS\Bucket::openDownloadStreamByName($filename, array $options = []); to retrieve the file
*/
$file = $gw->retrieveFileByName('3142184dbed342fbb5ad6dc495d02405');


$metadata = stream_get_meta_data($file['stream']);
rewind($file['stream']);

I get a "Warning: rewind(): stream does not support seeking" even though stream_get_meta_data function advertises that the stream is seekable

array (
  'timed_out' => false,
  'blocked' => true,
  'eof' => false,
  'wrapper_data' => '(removed for brevity)',
  'wrapper_type' => 'user-space',
  'stream_type' => 'user-space',
  'mode' => 'r',
  'unread_bytes' => 0,
  'seekable' => true,
  'uri' => 'gridfs://mydb/fileStore.files/585bc30888461f001a7a4412',
)

This behavior causes an error in Slim framework which tries to rewind the stream in the Response object if the stream is seekable before sending it out

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions