public Stream Read(string filePath) { var file = GDriveHelper.GetFileByPath(filePath); var request = service.Files.Get(file.FileId); MemoryStream memoryStream = new MemoryStream(); request.Download(memoryStream); return(memoryStream); }
public void Rename(string filePath, string newFileName) { var file = GDriveHelper.GetFileByPath(filePath); Google.Apis.Drive.v3.Data.File gfile = new Google.Apis.Drive.v3.Data.File() { Name = newFileName }; var updateRequest = service.Files.Update(gfile, file.FileId); updateRequest.Fields = "name"; updateRequest.Execute(); }
public void MoveTo(string sourceFilePath, string destiFilePath) { var file = GDriveHelper.GetFileByPath(sourceFilePath); var updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), file.FileId); GDriveDirectory gDriveDirectory = new GDriveDirectory(); if (!gDriveDirectory.Exists(destiFilePath)) { throw new DirectoryNotFoundException(destiFilePath + " does not exists"); } var tree = GDriveHelper.GetFolderTree(destiFilePath); var lastFolder = GDriveHelper.GetLastFolderInTree(tree); updateRequest.AddParents = lastFolder.FileId; updateRequest.RemoveParents = file.File.Parents[0]; updateRequest.Execute(); }
public bool Exists(string filePath) { return(GDriveHelper.GetFileByPath(filePath) != null); }
public void Delete(string filePath) { var file = GDriveHelper.GetFileByPath(filePath); service.Files.Delete(file.FileId); }
//TODO: Implement destiFilePath public void CopyTo(string sourceFilePath, string destiFilePath) { var file = GDriveHelper.GetFileByPath(sourceFilePath); service.Files.Copy(file.File, ""); }