9
9
use MongoDB \BSON \Binary ;
10
10
use MongoDB \BSON \ObjectId ;
11
11
use MongoDB \BSON \UTCDateTime ;
12
- use MongoDB \Operation \FindOneAndUpdate ;
12
+ use MongoDB \Operation \FindOneAndReplace ;
13
13
14
14
15
15
/**
@@ -48,8 +48,8 @@ protected function getGridFsFile()
48
48
$ gridFsFileQuery = $ this ->getGridFsFileQuery ();
49
49
$ changed = $ gridFsFileQuery ;
50
50
$ changed ['flowUpdated ' ] = new UTCDateTime ();
51
- $ this ->uploadGridFsFile = $ this ->config ->getGridFs ()->getFilesCollection ()->findOneAndUpdate ($ gridFsFileQuery , $ changed ,
52
- ['upsert ' => true , 'returnDocument ' => FindOneAndUpdate ::RETURN_DOCUMENT_AFTER ]);
51
+ $ this ->uploadGridFsFile = $ this ->config ->getGridFs ()->getFilesCollection ()->findOneAndReplace ($ gridFsFileQuery , $ changed ,
52
+ ['upsert ' => true , 'returnDocument ' => FindOneAndReplace ::RETURN_DOCUMENT_AFTER ]);
53
53
}
54
54
55
55
return $ this ->uploadGridFsFile ;
@@ -61,7 +61,7 @@ protected function getGridFsFile()
61
61
*/
62
62
public function chunkExists ($ index )
63
63
{
64
- return $ this ->config ->getGridFs ()->getFilesCollection ()->findOne ([
64
+ return $ this ->config ->getGridFs ()->getChunksCollection ()->findOne ([
65
65
'files_id ' => $ this ->getGridFsFile ()['_id ' ],
66
66
'n ' => (intval ($ index ) - 1 )
67
67
]) !== null ;
@@ -97,7 +97,7 @@ public function saveChunk($additionalUpdateOptions = [])
97
97
throw new Exception ("Invalid upload! (size: $ actualChunkSize) " );
98
98
}
99
99
$ chunk ['data ' ] = new Binary ($ data , Binary::TYPE_GENERIC );
100
- $ this ->config ->getGridFs ()->getFilesCollection ()->replaceOne ($ chunkQuery , $ chunk , array_merge (['upsert ' => true ], $ additionalUpdateOptions ));
100
+ $ this ->config ->getGridFs ()->getChunksCollection ()->replaceOne ($ chunkQuery , $ chunk , array_merge (['upsert ' => true ], $ additionalUpdateOptions ));
101
101
unlink ($ file ['tmp_name ' ]);
102
102
103
103
$ this ->ensureIndices ();
@@ -106,7 +106,7 @@ public function saveChunk($additionalUpdateOptions = [])
106
106
} catch (Exception $ e ) {
107
107
// try to remove a possibly (partly) stored chunk:
108
108
if (isset ($ chunkQuery )) {
109
- $ this ->config ->getGridFs ()->getFilesCollection ()->deleteMany ($ chunkQuery );
109
+ $ this ->config ->getGridFs ()->getChunksCollection ()->deleteMany ($ chunkQuery );
110
110
}
111
111
throw $ e ;
112
112
}
@@ -118,7 +118,7 @@ public function saveChunk($additionalUpdateOptions = [])
118
118
public function validateFile ()
119
119
{
120
120
$ totalChunks = intval ($ this ->request ->getTotalChunks ());
121
- $ storedChunks = $ this ->config ->getGridFs ()->getFilesCollection ()
121
+ $ storedChunks = $ this ->config ->getGridFs ()->getChunksCollection ()
122
122
->countDocuments (['files_id ' => $ this ->getGridFsFile ()['_id ' ]]);
123
123
return $ totalChunks === $ storedChunks ;
124
124
}
0 commit comments