MCPcopy Create free account
hub / github.com/plexdrive/plexdrive / GetFileById

Method GetFileById

drive/drive.go:268–296  ·  view source on GitHub ↗

GetFileById gets a Google Drive file by its id

(id string)

Source from the content-addressed store, hash-verified

266
267// GetFileById gets a Google Drive file by its id
268func (d *Client) GetFileById(id string) (*gdrive.File, error) {
269 client, err := d.getClient()
270 if nil != err {
271 Log.Debugf("%v", err)
272 return nil, fmt.Errorf("Could not get Google Drive client")
273 }
274
275 file, err := client.Files.
276 Get(id).
277 Fields(fields).
278 SupportsAllDrives(true).
279 Do()
280 if nil != err {
281 Log.Debugf("%v", err)
282 return nil, fmt.Errorf("Could not get object %v from API", id)
283 }
284
285 // getting file size
286 if 0 == file.Size && folderMimeType != file.MimeType && shortcutMimeType != file.MimeType {
287 res, err := client.Files.Get(id).SupportsAllDrives(true).Download()
288 if nil != err {
289 Log.Debugf("%v", err)
290 return nil, fmt.Errorf("Could not get file size for object %v", id)
291 }
292 file.Size = res.ContentLength
293 }
294
295 return file, nil
296}
297
298// GetRoot gets the root node directly from the API
299func (d *Client) GetRoot() (*APIObject, error) {

Callers 2

GetRootMethod · 0.95
mapFileToObjectMethod · 0.95

Calls 2

getClientMethod · 0.95
DownloadMethod · 0.80

Tested by

no test coverage detected