/// <summary> /// List the names of files in a bucket starting at a given name. /// </summary> /// <param name="bucketId">The bucket id to look for file names in.</param> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <IApiResults <ListFileNamesResponse> > IStorageFiles.ListNamesAsync (string bucketId) { var request = new ListFileNamesRequest(bucketId); return(await _client.ListFileNamesAsync(request, _cancellationToken)); }
/// <summary> /// Returns an enumerable that iterates through the names of all files in a bucket. /// </summary> /// <param name="request">The list of file name request to send.</param> /// <param name="cacheTTL">An absolute cache expiration time to live (TTL) relative to now.</param> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <IEnumerable <FileItem> > IStorageFiles.GetEnumerableAsync (ListFileNamesRequest request, TimeSpan cacheTTL) { var enumerable = new FileNameEnumerable(_client, _logger, request, cacheTTL, _cancellationToken) as IEnumerable <FileItem>; return(await Task.FromResult(enumerable).ConfigureAwait(false)); }
static ListFileNamesResponse ListFileNames(ListFileNamesRequest request, string apiUrl, string authToken) { var headers = GetAuthHeaders(authToken); string responseString = MakeRequest2(string.Format("{0}/b2api/v1/b2_list_file_names", apiUrl), headers, JsonConvert.SerializeObject(request)).Result; return(JsonConvert.DeserializeObject <ListFileNamesResponse>(responseString)); }
private byte[] GetPayload(string startFileName, string startFileID, ListFileMethod method) { byte[] payload; if (method == ListFileMethod.FILE_NAMES) { ListFileNamesRequest request = new ListFileNamesRequest { BucketID = _bucketID, MaxFileCount = 10000, StartFileName = startFileName, }; payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(request)); } else { ListFileVersionsRequest request = new ListFileVersionsRequest { BucketID = _bucketID, MaxFileCount = 10000, StartFileID = startFileID, StartFileName = startFileName, }; payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(request)); } return(payload); }
public async Task GetFileNameEnumerable() { var request = new ListFileNamesRequest(BucketId); var enumerable = await Storage.Files.GetEnumerableAsync(request); Assert.Equal(typeof(FileNameEnumerable), enumerable.GetType()); Assert.Equal(_fileSystem.AllFiles.Count(), enumerable.ToList().Count()); }
/// <summary> /// Returns the first file item that satisfies a specified condition. /// </summary> /// <param name="request">The list of file name request to send.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <param name="cacheTTL">An absolute cache expiration time to live (TTL) relative to now.</param> /// <exception cref="InvalidOperationException">No element satisfies the condition in predicate or the source sequence is empty.</exception> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <FileItem> IStorageFiles.FirstAsync (ListFileNamesRequest request, Func <FileItem, bool> predicate, TimeSpan cacheTTL) { return(await Task.Run(() => { var adapter = new FileNameEnumerable(_client, _logger, request, cacheTTL, _cancellationToken) as IEnumerable <FileItem>; return adapter.First(predicate); })); }
/// <summary> /// List the names of files in a bucket starting at a given name. /// </summary> /// <param name="request">The list of file name request to send.</param> /// <param name="cacheTTL">An absolute cache expiration time to live (TTL) relative to now.</param> /// <exception cref="AuthenticationException">Thrown when authentication fails.</exception> /// <exception cref="ApiException">Thrown when an error occurs during client operation.</exception> async Task <IApiResults <ListFileNamesResponse> > IStorageFiles.ListNamesAsync (ListFileNamesRequest request, TimeSpan cacheTTL) { return(await _client.ListFileNamesAsync(request, cacheTTL, _cancellationToken)); }
/// <summary> /// Initializes a new instance of the <see cref="FileNameEnumerable"/> class. /// </summary> public FileNameEnumerable(IApiClient client, ILogger logger, ListFileNamesRequest request, TimeSpan cacheTTL, CancellationToken cancellationToken) : base(client, logger, cacheTTL, cancellationToken) { _request = request; }