Get size of file by id with Google Drive API v3 PHP

Viewed 399

I need to get the file size by id with google drive API v3 and php. I use google drive API client library v3. I can connect to google disk but I don't know how to get one file size by its id.

1 Answers

I'm sorry, it was just sleepless night.

            $drive = new Google_Service_Drive($client);
            $file_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

            $optpParams = array(
                'fields' => "size"
                );
                
            $response = $drive->files->get($file_id, $optpParams);
            echo $response->size;
Related