How to update metadata of file in GridFS
averichev opened this issue · comments
averichev commented
Please, tell me, how i can update file metadata after write.
my code
$gridFSAdapter->write($fileName, $file->getContent());
$gridFSAdapter->setMetadata($fileName, [
'mimeType' => $uploadedFile->getMimeType(),
'clientOriginalExtension' => $uploadedFile->getClientOriginalExtension(),
'clientOriginalName' => $uploadedFile->getClientOriginalName(),
'uploadUserId' => $this->getUser()->getId(),
]);
@NiR- ?
nm2107 commented
Hello,
From the gridFS code, the setMetadata
function only stores it in memory : https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Adapter/GridFS.php#L153-L159
you have to call write
to persist the metadata on the storage : https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Adapter/GridFS.php#L51-L65
so, with your snippet :
$gridFSAdapter->getMetadata($key , $value);
$gridFSAdapter->write($key, $content);