public Mock<IAsyncCloudGateway> InitializeGetChildItemsAsyncWithFilter(RootName rootName, string path, string filter, params IEnumerable<FileSystemInfoContract>[] pathChildItems) { var gatewayMock = new Mock<IAsyncCloudGateway>(MockBehavior.Strict); gatewayMock.SetupSequence(g => g.GetRootAsync(rootName, FileSystemFixture.ApiKey)) .ReturnsAsync(FileSystemFixture.Root) .ThrowsAsync(new InvalidOperationException("Redundant call to GetRoot()")); gatewayMock.SetupSequence(g => g.GetDriveAsync(rootName, FileSystemFixture.ApiKey)) .ReturnsAsync(FileSystemFixture.Drive) .Throws(new InvalidOperationException("Redundant call to GetDrive()")); if (path != null) { path = path + Path.DirectorySeparatorChar; for (int i = 0, j = 0; i >= 0; i = path.IndexOf(Path.DirectorySeparatorChar, Math.Min(path.Length, i + 2)), ++j) { var currentPath = new DirectoryId(path.Substring(0, Math.Max(1, i))); bool applyFilter = j == pathChildItems.Length - 1; var effectiveFilter = applyFilter && filter != null ? new Regex("^" + filter.Replace("*", ".*") + "$") : null; gatewayMock.SetupSequence(g => g.GetChildItemAsync(rootName, currentPath)) .ReturnsAsync(applyFilter ? pathChildItems[j].Where(f => effectiveFilter == null || effectiveFilter.IsMatch(f.Name)) : pathChildItems[j]) .ThrowsAsync(new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Redundant access to {0}", currentPath))); } } return gatewayMock; }
public RootDirectoryInfoContract GetRoot(RootName root, string apiKey) { if (root == null) throw new ArgumentNullException(nameof(root)); var directory = new DirectoryInfo(root.Root); return new RootDirectoryInfoContract(Path.DirectorySeparatorChar.ToString(), directory.CreationTime, directory.LastWriteTime); }
public DriveInfoContract GetDrive(RootName root, string apiKey) { if (root == null) throw new ArgumentNullException(nameof(root)); var drive = new DriveInfo(root.Root); return new DriveInfoContract(drive.Name, drive.AvailableFreeSpace, drive.TotalSize - drive.AvailableFreeSpace); }
public TestDirectory(IAsyncCloudGateway gateway, RootName root, string apiKey, string path) { this.gateway = gateway; this.root = root; var rootDirectory = gateway.GetRootAsync(root, apiKey).Result; directory = gateway.NewDirectoryItemAsync(root, rootDirectory.Id, path).Result; }
public async Task <RootDirectoryInfoContract> GetRootAsync(RootName root, string apiKey, IDictionary <string, string> parameters) { var context = await RequireContextAsync(root, apiKey); var accessToken = context.Client.RetryManager.AuthManager.Credentials.Password; var item = hubiCInfo.QueryData <hubiCAccount>(hubiCInfo.AccountUri, accessToken); return(new RootDirectoryInfoContract("/", item.CreationDate, item.CreationDate)); }
public async Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var locator = locatorResolver(); var item = await AsyncFunc.Retry <FileSystem, ServerException>(async() => await context.Client.FileSystemManager.UploadNewFileStreamAsync(locator.ParentId.Value, locator.Name, new ProgressStream(content, progress), true), RETRIES); return(true); }
public async Task <DirectoryInfoContract> NewDirectoryItemAsync(RootName root, DirectoryId parent, string name) { var context = await RequireContextAsync(root); var itemReference = ODConnection.ItemReferenceForItemId(parent.Value, context.Drive.Id); var item = await AsyncFunc.RetryAsync <ODItem, ODException>(async() => await context.Connection.CreateFolderAsync(itemReference, name), RETRIES); return(new DirectoryInfoContract(item.Id, item.Name, item.CreatedDateTime, item.LastModifiedDateTime)); }
public async Task <bool> RemoveItemAsync(RootName root, FileSystemId target, bool recurse) { var context = await RequireContextAsync(root); var itemReference = ODConnection.ItemReferenceForItemId(target.Value, context.Drive.Id); var success = await AsyncFunc.RetryAsync <bool, ODException>(async() => await context.Connection.DeleteItemAsync(itemReference, ItemDeleteOptions.Default), RETRIES); return(success); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContextAsync(root); var itemReference = ODConnection.ItemReferenceForItemId(source.Value, context.Drive.Id); var stream = await AsyncFunc.RetryAsync <Stream, ODException>(async() => await context.Connection.DownloadStreamForItemAsync(itemReference, StreamDownloadOptions.Default), RETRIES); return(stream); }
public async Task <IEnumerable <FileSystemInfoContract> > GetChildItemAsync(RootName root, DirectoryId parent) { var context = await RequireContextAsync(root); var itemReference = ODConnection.ItemReferenceForItemId(parent.Value, context.Drive.Id); var items = await AsyncFunc.RetryAsync <ODItemCollection, ODException>(async() => await context.Connection.GetChildrenOfItemAsync(itemReference, ChildrenRetrievalOptions.Default), RETRIES); return(items.Collection.Select(i => i.ToFileSystemInfoContract())); }
public async Task <FileInfoContract> NewFileItemAsync(RootName root, DirectoryId parent, string name, Stream content, IProgress <ProgressValue> progress) { var context = await RequireContext(root); var tokenSource = new CancellationTokenSource(); var item = await AsyncFunc.Retry <pCloudFile, pCloudException>(async() => await context.Client.UploadFileAsync(new ProgressStream(content, progress), ToId(parent), name, tokenSource.Token), RETRIES); return(new FileInfoContract(item.Id, item.Name, item.Created, item.Modified, item.Size, null)); }
public async Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContextAsync(root); var retryPolicyWithAction = Policy.Handle <Exception>().WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, ts) => content.Seek(0, SeekOrigin.Begin)); var putFileResponse = await retryPolicyWithAction.ExecuteAsync(() => context.Client.PutFile(target.Value, content)); return(putFileResponse.IsSuccessful); }
public async Task <RootDirectoryInfoContract> GetRootAsync(RootName root, string apiKey, IDictionary <string, string> parameters) { var context = await RequireContextAsync(root, apiKey); var item = await AsyncFunc.RetryAsync <FileSystem, ServerException>(async() => await context.Client.GetRootFolder(), RETRIES); var user = await AsyncFunc.RetryAsync <User, ServerException>(async() => await context.Client.UserManager.GetUserAsync(), RETRIES); return(new RootDirectoryInfoContract(item.Id, DateTimeOffset.FromFileTime(Math.Max(0, user.CreatedTime)), DateTimeOffset.FromFileTime(Math.Max(0, item.ModifiedTime.Ticks)))); }
public FileInfoContract NewFileItem(RootName root, DirectoryId parent, string name, Stream content, IProgress <ProgressValue> progress) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var item = context.Client.Upload(new ProgressStream(content, progress), name, parentItem); return(new FileInfoContract(item.Id, item.Name, DateTimeOffset.MinValue, item.LastModificationDate, item.Size, null)); }
public async Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var locator = locatorResolver(); var tokenSource = new CancellationTokenSource(); await context.Client.UploadFileAsync(content, ToId(locator.ParentId), locator.Name, tokenSource.Token); return(true); }
public async Task <bool> ClearContentAsync(RootName root, FileId target, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContextAsync(root); var link = await context.Client.Files.GetUploadLinkAsync(target.Value, true, CancellationToken.None); await context.Client.Files.UploadAsync(link, Stream.Null, CancellationToken.None); return(true); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContextAsync(root); var stream = new MemoryStream(); await AsyncFunc.RetryAsync <GoogleApiException>(async() => await context.Service.Files.Get(source.Value).DownloadAsync(stream), RETRIES); stream.Seek(0, SeekOrigin.Begin); return(stream); }
async Task <bool> Transact(RootName root, Func <ulong, LocalEvent> getEvent) { var context = await RequireContextAsync(root); var e = getEvent(_sequenceNr.Next); var result = context.Writer.Transact(e); //if (info) _sequenceNr.Increment(); return(result); }
public async Task <bool> RemoveItemAsync(RootName root, FileSystemId target, bool recurse) { var context = await RequireContextAsync(root); var success = target is DirectoryId ? await retryPolicy.ExecuteAsync(() => context.Client.FoldersManager.DeleteAsync(target.Value, recurse)) : await retryPolicy.ExecuteAsync(() => context.Client.FilesManager.DeleteAsync(target.Value)); return(success); }
public async Task <bool> RemoveItemAsync(RootName root, FileSystemId target, bool recurse) { var context = await RequireContext(root); var success = target is DirectoryId ? await AsyncFunc.Retry <bool, BoxException>(async() => await context.Client.FoldersManager.DeleteAsync(target.Value, recurse), RETRIES) : await AsyncFunc.Retry <bool, BoxException>(async() => await context.Client.FilesManager.DeleteAsync(target.Value), RETRIES); return(success); }
public async Task <IEnumerable <FileSystemInfoContract> > GetChildItemAsync(RootName root, DirectoryId parent) { var context = await RequireContextAsync(root); var item = await AsyncFunc.RetryAsync <ListedFolder, pCloudException>(async() => await context.Client.ListFolderAsync(ToId(parent)), RETRIES); var items = item.Contents; return(items.Select(i => i.ToFileSystemInfoContract())); }
public IEnumerable <FileSystemInfoContract> GetChildItem(RootName root, DirectoryId parent) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var items = context.Client.GetNodes(parentItem); return(items.Select(i => i.ToFileSystemInfoContract())); }
public async Task <RootDirectoryInfoContract> GetRootAsync(RootName root, string apiKey, IDictionary <string, string> parameters) { var context = await RequireContextAsync(root, apiKey); var item = await retryPolicy.ExecuteAsync(() => context.Client.GetRootFolder()); var user = await retryPolicy.ExecuteAsync(() => context.Client.UserManager.GetUserAsync()); return(new RootDirectoryInfoContract(item.Id, DateTimeOffset.FromFileTime(Math.Max(0, user.CreatedTime)), DateTimeOffset.FromFileTime(Math.Max(0, item.ModifiedTime.Ticks)))); }
public Stream GetContent(RootName root, FileId source) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var item = nodes.Single(n => n.Id == source.Value); var stream = context.Client.Download(item); return(stream); }
public async Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContextAsync(root); var retryPolicyWithAction = Policy.Handle <OneDriveException>().WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, ts) => content.Seek(0, SeekOrigin.Begin)); var item = await retryPolicyWithAction.ExecuteAsync(() => context.Client.Drive.Items[target.Value].Content.Request().PutAsync <Item>(content)); return(true); }
public DirectoryInfoContract NewDirectoryItem(RootName root, DirectoryId parent, string name) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var item = context.Client.CreateFolder(name, parentItem); return(new DirectoryInfoContract(item.Id, item.Name, DateTimeOffset.MinValue, item.LastModificationDate)); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContextAsync(root); var link = await context.Client.Files.GetDownloadLinkAsync(source.Value, CancellationToken.None); var stream = await context.Client.Files.DownloadAsync(link, CancellationToken.None); return(stream); }
public async Task <bool> ClearContentAsync(RootName root, FileId target, Func <FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var locator = locatorResolver(); var tokenSource = new CancellationTokenSource(); await context.Client.UploadFileAsync(new MemoryStream(), ToId(locator.ParentId), locator.Name, tokenSource.Token); return(true); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContextAsync(root); var getRawFileResponse = await context.Client.GetRawFile(source.Value); CheckSuccess(getRawFileResponse, nameof(WebDavClient.GetRawFile), source.Value); return(getRawFileResponse.Stream); }
public async Task <IEnumerable <FileSystemInfoContract> > GetChildItemAsync(RootName root, DirectoryId parent) { var context = await RequireContextAsync(root); var item = await retryPolicy.ExecuteAsync(() => context.Client.ListFolderAsync(ToId(parent))); var items = item.Contents; return(items.Select(i => i.ToFileSystemInfoContract())); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContextAsync(root); var itemReference = await retryPolicy.ExecuteAsync(() => context.Service.Files.Get(source.Value).ExecuteAsync()); var stream = await retryPolicy.ExecuteAsync(() => context.Service.HttpClient.GetStreamAsync(itemReference.DownloadUrl)); return(stream); }
public async Task <bool> TryAuthenticateAsync(RootName root, string apiKey, IDictionary <string, string> parameters) { try { await RequireContextAsync(root, apiKey); return(true); } catch (AuthenticationException) { return(false); } }
public async Task <RootDirectoryInfoContract> GetRootAsync(RootName root, string apiKey, IDictionary <string, string> parameters) { var context = await RequireContextAsync(root, apiKey); var nodes = await context.Client.GetNodesAsync(); var item = nodes.Single(n => n.Type == NodeType.Root); return(new RootDirectoryInfoContract(item.Id, DateTimeOffset.FromFileTime(0), item.LastModificationDate)); }
private MegaContext RequireContext(RootName root, string apiKey = null) { if (root == null) throw new ArgumentNullException(nameof(root)); var result = default(MegaContext); if (!contextCache.TryGetValue(root, out result)) { var client = Authenticator.Login(root.UserName, apiKey); contextCache.Add(root, result = new MegaContext(client)); } return result; }
internal ICloudDrive CreateCloudDrive(string schema, string userName, string root, CloudDriveParameters parameters) { var rootName = new RootName(schema, userName, root); var asyncGateway = default(IAsyncCloudGateway); if (GatewayManager.TryGetAsyncCloudGatewayForSchema(rootName.Schema, out asyncGateway)) return new AsyncCloudDrive(rootName, asyncGateway, parameters); var gateway = default(ICloudGateway); if (GatewayManager.TryGetCloudGatewayForSchema(rootName.Schema, out gateway)) return new CloudDrive(rootName, gateway, parameters); throw new KeyNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.NoGatewayForSchema, rootName.Schema)); }
private async Task<GDriveContext> RequireContext(RootName root, string apiKey = null) { if (root == null) throw new ArgumentNullException(nameof(root)); var result = default(GDriveContext); if (!contextCache.TryGetValue(root, out result)) { var clientSecret = new ClientSecrets() { ClientId = Secrets.CLIENT_ID, ClientSecret = Secrets.CLIENT_SECRET }; var credentials = await GoogleWebAuthorizationBroker.AuthorizeAsync(clientSecret, new[] { DriveService.Scope.Drive }, root.UserName, System.Threading.CancellationToken.None); var service = new DriveService(new BaseClientService.Initializer() { HttpClientInitializer = credentials, ApplicationName = "GDrvTest" }); contextCache.Add(root, result = new GDriveContext(service)); } return result; }
public IEnumerable<FileSystemInfoContract> GetChildItem(RootName root, DirectoryId parent) { if (root == null) throw new ArgumentNullException(nameof(root)); if (parent == null) throw new ArgumentNullException(nameof(parent)); var effectivePath = GetFullPath(root, parent.Value); var directory = new DirectoryInfo(effectivePath); if (directory.Exists) return directory.EnumerateDirectories().Select(d => new DirectoryInfoContract(GetRelativePath(root, d.FullName), d.Name, d.CreationTime, d.LastWriteTime)).Cast<FileSystemInfoContract>().Concat( directory.EnumerateFiles().Select(f => new FileInfoContract(GetRelativePath(root, f.FullName), f.Name, f.CreationTime, f.LastWriteTime, f.Length, null)).Cast<FileSystemInfoContract>()); else return new FileSystemInfoContract[] { }; }
public FileSystemInfoContract RenameItem(RootName root, FileSystemId target, string newName) { throw new NotSupportedException(Resources.RenamingOfFilesNotSupported); }
public FileInfoContract NewFileItem(RootName root, DirectoryId parent, string name, Stream content, IProgress<ProgressValue> progress) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var item = context.Client.Upload(new ProgressStream(content, progress), name, parentItem); return new FileInfoContract(item.Id, item.Name, DateTimeOffset.MinValue, item.LastModificationDate, item.Size, null); }
public void RemoveItem(RootName root, FileSystemId target, bool recurse) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var item = nodes.Single(n => n.Id == target.Value); context.Client.Delete(item); }
public FileSystemInfoContract MoveItem(RootName root, FileSystemId source, string moveName, DirectoryId destination) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var sourceItem = nodes.Single(n => n.Id == source.Value); if (!string.IsNullOrEmpty(moveName) && moveName != sourceItem.Name) throw new NotSupportedException(Resources.RenamingOfFilesNotSupported); var destinationParentItem = nodes.Single(n => n.Id == destination.Value); var item = context.Client.Move(sourceItem, destinationParentItem); return item.ToFileSystemInfoContract(); }
public DirectoryInfoContract NewDirectoryItem(RootName root, DirectoryId parent, string name) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var item = context.Client.CreateFolder(name, parentItem); return new DirectoryInfoContract(item.Id, item.Name, DateTimeOffset.MinValue, item.LastModificationDate); }
public RootDirectoryInfoContract GetRoot(RootName root, string apiKey) { var context = RequireContext(root, apiKey); var nodes = context.Client.GetNodes(); var item = nodes.Single(n => n.Type == NodeType.Root); return new RootDirectoryInfoContract(item.Id, DateTimeOffset.MinValue, item.LastModificationDate); }
public async Task<bool> RemoveItemAsync(RootName root, FileSystemId target, bool recurse) { var context = await RequireContext(root); var item = await AsyncFunc.Retry<string, GoogleApiException>(async () => await context.Service.Files.Delete(target.Value).ExecuteAsync(), RETRIES); return true; }
public async Task<bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress<ProgressValue> progress, Func<FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var itemReference = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await context.Service.Files.Get(target.Value).ExecuteAsync(), RETRIES); var update = context.Service.Files.Update(itemReference, target.Value, content, itemReference.MimeType); update.ProgressChanged += p => progress.Report(new ProgressValue((int)p.BytesSent, (int)content.Length)); await AsyncFunc.Retry<IUploadProgress, GoogleApiException>(async () => await update.UploadAsync(), RETRIES); return true; }
public Stream GetContent(RootName root, FileId source) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var item = nodes.Single(n => n.Id == source.Value); var stream = context.Client.Download(item); return stream; }
public AsyncCloudDrive(RootName rootName, IAsyncCloudGateway gateway, CloudDriveParameters parameters) : base(rootName, parameters) { this.gateway = gateway; }
public async Task<FileSystemInfoContract> MoveItemAsync(RootName root, FileSystemId source, string moveName, DirectoryId destination, Func<FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var move = new GoogleFile() { Parents = new[] { new ParentReference() { Id = destination.Value } }, Title = moveName }; var patch = context.Service.Files.Patch(move, source.Value); var item = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await patch.ExecuteAsync(), RETRIES); return item.ToFileSystemInfoContract(); }
public async Task<DirectoryInfoContract> NewDirectoryItemAsync(RootName root, DirectoryId parent, string name) { var context = await RequireContext(root); var file = new GoogleFile() { Title = name, MimeType = MIME_TYPE_DIRECTORY, Parents = new[] { new ParentReference() { Id = parent.Value } } }; var item = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await context.Service.Files.Insert(file).ExecuteAsync(), RETRIES); return new DirectoryInfoContract(item.Id, item.Title, new DateTimeOffset(item.CreatedDate.Value), new DateTimeOffset(item.ModifiedDate.Value)); }
public async Task<FileInfoContract> NewFileItemAsync(RootName root, DirectoryId parent, string name, Stream content, IProgress<ProgressValue> progress) { var context = await RequireContext(root); var file = new GoogleFile() { Title = name, MimeType = MIME_TYPE_FILE, Parents = new[] { new ParentReference() { Id = parent.Value } } }; var insert = context.Service.Files.Insert(file, content, MIME_TYPE_FILE); insert.ProgressChanged += p => progress.Report(new ProgressValue((int)p.BytesSent, (int)content.Length)); var upload = await AsyncFunc.Retry<IUploadProgress, GoogleApiException>(async () => await insert.UploadAsync(), RETRIES); var item = insert.ResponseBody; return new FileInfoContract(item.Id, item.Title, new DateTimeOffset(item.CreatedDate.Value), new DateTimeOffset(item.ModifiedDate.Value), item.FileSize.Value, item.Md5Checksum); }
public CloudDrive(PSDriveInfo driveInfo, RootName rootName, ICloudGateway gateway, CloudDriveParameters parameters) : base(driveInfo, rootName, parameters) { this.gateway = gateway; }
public async Task<FileSystemInfoContract> CopyItemAsync(RootName root, FileSystemId source, string copyName, DirectoryId destination, bool recurse) { var context = await RequireContext(root); var copy = new GoogleFile() { Title = copyName }; if (destination != null) copy.Parents = new[] { new ParentReference() { Id = destination.Value } }; var item = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await context.Service.Files.Copy(copy, source.Value).ExecuteAsync(), RETRIES); return item.ToFileSystemInfoContract(); }
public void SetContent(RootName root, FileId target, Stream content, IProgress<ProgressValue> progress) { throw new NotSupportedException(Resources.SettingOfFileContentNotSupported); }
public DriveInfoContract GetDrive(RootName root, string apiKey) { if (root == null) throw new ArgumentNullException(nameof(root)); return new DriveInfoContract(root.Value, null, null); }
public FileSystemInfoContract CopyItem(RootName root, FileSystemId source, string copyName, DirectoryId destination, bool recurse) { throw new NotSupportedException(Resources.CopyingOfFilesNotSupported); }
public IEnumerable<FileSystemInfoContract> GetChildItem(RootName root, DirectoryId parent) { var context = RequireContext(root); var nodes = context.Client.GetNodes(); var parentItem = nodes.Single(n => n.Id == parent.Value); var items = context.Client.GetNodes(parentItem); return items.Select(i => i.ToFileSystemInfoContract()); }
public async Task<FileSystemInfoContract> RenameItemAsync(RootName root, FileSystemId target, string newName, Func<FileSystemInfoLocator> locatorResolver) { var context = await RequireContext(root); var patch = context.Service.Files.Patch(new GoogleFile() { Title = newName }, target.Value); var item = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await patch.ExecuteAsync(), RETRIES); return item.ToFileSystemInfoContract(); }
public async Task<Stream> GetContentAsync(RootName root, FileId source) { var context = await RequireContext(root); var itemReference = await AsyncFunc.Retry<GoogleFile, GoogleApiException>(async () => await context.Service.Files.Get(source.Value).ExecuteAsync(), RETRIES); //var stream = new MemoryStream(await AsyncFunc.Retry<byte[], GoogleApiException>(async () => await context.Service.HttpClient.GetByteArrayAsync(itemReference.DownloadUrl), RETRIES)); var stream = await AsyncFunc.Retry<Stream, GoogleApiException>(async () => await context.Service.HttpClient.GetStreamAsync(itemReference.DownloadUrl), RETRIES); return stream; }
public void ClearContent(RootName root, FileId target) { throw new NotSupportedException(Resources.SettingOfFileContentNotSupported); }