/// <summary> /// Gets a file's metadata by ID. /// Documentation https://developers.google.com/drive/v2/reference/files/get /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Drive service.</param> /// <param name="fileId">The ID for the file in question.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>FileResponse</returns> public static File Get(DriveService service, string fileId, FilesGetOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (fileId == null) { throw new ArgumentNullException(fileId); } // Building the initial request. var request = service.Files.Get(fileId); // Applying optional parameters to the request. request = (FilesResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Files.Get failed.", ex); } }
/// <summary> /// Gets a file's metadata or content by ID. /// Documentation https://developers.google.com/drive/v3/reference/files/get /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Drive service.</param> /// <param name="fileId">The ID of the file.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>FileResponse</returns> public async Task <File> Get(string fileId, FilesGetOptionalParms optional = null) { try { // Initial validation. if (_service == null) { throw new ArgumentNullException("service"); } if (fileId == null) { throw new ArgumentNullException(fileId); } // Building the initial request. var request = _service.Files.Get(fileId); // Applying optional parameters to the request. request = (FilesResource.GetRequest)GoogleDriveFunctionsHelper.ApplyOptionalParms(request, optional); // Requesting data. return(await request.ExecuteAsync()); } catch (Exception ex) { throw new Exception("Request Files.Get failed.", ex); } }