/// <summary> /// Gets a handle for the specified file or folder. /// </summary> public GoogleDriveHandle GetHandle(string path) { Ensure.NotNull(path, "path"); var segments = GoogleDrivePath.Split(path); if (segments.Length == 0 || path.EqualsOrdIgnoreCase(ROOT)) { var root = GetItemInfoById(ROOT); return(root); } var queue = new Queue <string>(segments); if (IsRoot(segments[0])) { queue.Dequeue(); } var info = GetItemInfo(ROOT, queue); if (info == null) { return(null); } var handle = new GoogleDriveHandle(info); return(handle); }
/// <summary> /// Creates a file /// </summary> public GoogleDriveHandle CreateFile(string parentId, string name) { Ensure.NotNull(parentId, "parentId"); var body = new GoogleDriveRequestBody(); body.SetTitle(name); body.SetParent(parentId); var res = Post(ApiUrls.Files(), body); var handle = new GoogleDriveHandle(res.Data); return(handle); }
public GoogleDriveStream(FileSystemFile file, Action<FileSystemStream> disposeAction) : base(file, disposeAction) { m_Handle = (GoogleDriveHandle)file.Handle; m_Session = file.Session as GoogleDriveSession; }
/// <summary> /// Gets a handle for the specified file or folder. /// </summary> public GoogleDriveHandle GetHandle(string path) { Ensure.NotNull(path, "path"); var segments = GoogleDrivePath.Split(path); if (segments.Length == 0 || path.EqualsOrdIgnoreCase(ROOT)) { var root = GetItemInfoById(ROOT); return root; } var queue = new Queue<string>(segments); if (IsRoot(segments[0])) { queue.Dequeue(); } var info = GetItemInfo(ROOT, queue); if (info == null) { return null; } var handle = new GoogleDriveHandle(info); return handle; }
/// <summary> /// Creates a file /// </summary> public GoogleDriveHandle CreateFile(string parentId, string name) { Ensure.NotNull(parentId, "parentId"); var body = new GoogleDriveRequestBody(); body.SetTitle(name); body.SetParent(parentId); var res = Post(ApiUrls.Files(), body); var handle = new GoogleDriveHandle(res.Data); return handle; }