Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
acid24 opened this issue Dec 22, 2016 · 4 comments
Closed

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

acid24 opened this issue Dec 22, 2016 · 4 comments

Comments

@acid24
Copy link

acid24 commented Dec 22, 2016

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

@jmikola
Copy link
Member

jmikola commented Dec 22, 2016

Seeking GridFS streams is an outstanding feature, which is being tracked in PHPLIB-213.

Based on discussion in https://github.com/fruux/sabre-dav/issues/787, StreamWrapper implementations have no control over the "seekable" property of stream_get_meta_data() and always advertise themselves as seekable. Slim may want to implement similar fseek() checks that went into sabre-dav to address this (not just for GridFS but other StreamWrappers that do not support seeking).

/cc @codeguy @akrabat

@jmikola
Copy link
Member

jmikola commented Jan 12, 2017

@acid24: We have an implementation of seeking for readable streams in #325 if you'd like to test that out. Since it's a new feature, it will not be released until 1.2.0; however, I'd be interested to hear whether it meets your needs.

In the meantime, I'm going to close this issue. Please watch PHPLIB-213 or the above PR for further updates.

@jmikola jmikola closed this as completed Jan 12, 2017
@acid24
Copy link
Author

acid24 commented Jan 13, 2017

@jmikola OK, I will test it and let you know. Thank you

@jmikola
Copy link
Member

jmikola commented Mar 16, 2017

1.2.0-alpha1 is now tagged and includes seeking functionality for GridFS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants