Skip to content

Commit 55ec9d8

Browse files
committed
removing custom write method
1 parent 327f688 commit 55ec9d8

File tree

2 files changed

+0
-29
lines changed

2 files changed

+0
-29
lines changed

src/Flow/Mongo/MongoFile.php

-26
Original file line numberDiff line numberDiff line change
@@ -182,30 +182,4 @@ protected function getGridFsFileQuery()
182182
'length' => intval($this->request->getTotalSize())
183183
];
184184
}
185-
186-
/**
187-
* Saves an uploaded file to disk. Must have been stored via {@link saveToGridFs} before.
188-
*
189-
* Note: conventional {@link \MongoGridFSFile::write} might fail on some platforms/driver versions - use this method.
190-
*
191-
* @param \MongoGridFS $gridFS
192-
* @param \MongoId $fileId id of grid fs file
193-
* @param string $fileName absolute or relative file name (existing file is deleted)
194-
* @return bool true on successful write and false on failure
195-
*/
196-
public static function writeFile(\MongoGridFS $gridFS, \MongoId $fileId, $fileName)
197-
{
198-
if (file_exists($fileName)) {
199-
unlink($fileName);
200-
}
201-
$chunkEntries = $gridFS->chunks->find(['files_id' => $fileId])->sort(['n' => 1]);
202-
foreach ($chunkEntries as $chunkEntry) {
203-
/** @var \MongoBinData $data */
204-
$data = $chunkEntry['data'];
205-
if (!file_put_contents($fileName, $data->bin, FILE_APPEND)) {
206-
return false;
207-
}
208-
}
209-
return true;
210-
}
211185
}

src/Flow/Mongo/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ if ($file->validateFile()) {
3838
}
3939
```
4040

41-
To write a file to disk one might prefer `\Flow\Mongo\MongoFile::writeFile($gridFs, $fileId, $file)` over conventional
42-
`\MongoGridFsFile::write($file)`, as the latter is not integrating on all platforms/drivers with this implementation.
43-
4441
Delete unfinished files
4542
-----------------------
4643

0 commit comments

Comments
 (0)