How can I get uploaded file's id?
Jervi-sir opened this issue · 1 comments
Jervi-sir commented
I need to access this id variable shown in image below, so I can store it in database
here the code I used to build the uploader controller
Storage::extend('google', function ($app, $config) {
$client = new Google_Client();
$client->setClientId($config['clientId']);
$client->setClientSecret($config['clientSecret']);
$client->refreshToken($config['refreshToken']);
$service = new Google_Service_Drive($client);
$adapter = new GoogleDriveAdapter($service, $config['scheduleFolderId']);
return new Filesystem($adapter);
});
$disk = Storage::disk('google');
...
$img = Image::make($image)->orientate()->encode('jpg', 50);
$img->encode();
$disk->put($file_name, $img->getEncoded());
dd($disk);
I have made some changes in order to access it, but issue the change must be in vendor class GoogleDriveAdapter.php
with following code
public function getCacheFileObjectsByName()
{
return array_values($this->cacheFileObjectsByName)[0];
}
and in laravel UploaderController, I used
$file_id = $disk->getDriver()->getAdapter()->getCacheFileObjectsByName()->id
My question is, how can I make the change I made in vendor file, outside vendor folder, so I can correctly use it in production
PaolaRuby commented
Maybe this package don't has support
I use masbug/flysystem-google-drive-ext, it has the same config, and getMetadata
gets me that id
$disk->getDriver()->getAdapter()->getMetadata($file_name);