Skip to content

Upload methods for GridFS make unnecessary query #2107

Open
@alcaeus

Description

@alcaeus

(originally reported as https://jira.mongodb.org/browse/PHPLIB-486)

When using DefaultGridFSRepository::uploadFromStream, the repository class runs a proxy object for the GridFS file with the ID returned from MongoDB\GridFS\Bucket::uploadFromStream. This results in a database query when accessing the file proxy, which is unnecessary as the stream wrappers keep a copy of the document in memory.

This extra query can be avoided by not using the uploadFromStream and uploadFromFile methods, but rather using openUploadStream and stream_copy_to_stream in conjunction with Bucket::getFileDocumentForStream to return the actual document instead of a proxy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions