/// <summary> /// Downloads one file from B2. /// </summary> /// <param name="fileId"></param> /// <param name="cancelToken"></param> /// <returns></returns> public async Task <B2DownloadAuthorization> GetDownloadAuthorization(string fileNamePrefix, int validDurationInSeconds, string bucketId = "", string b2ContentDisposition = "", CancellationToken cancelToken = default(CancellationToken)) { var operationalBucketId = Utilities.DetermineBucketId(_options, bucketId); var request = FileDownloadRequestGenerators.GetDownloadAuthorization(_options, fileNamePrefix, validDurationInSeconds, operationalBucketId, b2ContentDisposition); // Send the download request var response = await _client.SendAsync(request, cancelToken); // Create B2File from response return(await ResponseParser.ParseResponse <B2DownloadAuthorization>(response, _api)); }
/// <summary> /// Downloads one file from B2. /// </summary> /// <param name="fileId"></param> /// <param name="cancelToken"></param> /// <returns></returns> public async Task <B2File> DownloadById(string fileId, CancellationToken cancelToken = default(CancellationToken)) { // Are we searching by name or id? HttpRequestMessage request; request = FileDownloadRequestGenerators.DownloadById(_options, fileId); // Send the download request var response = await _client.SendAsync(request, cancelToken); // Create B2File from response return(await ParseDownloadResponse(response)); }
/// <summary> /// Downloads a file part by providing the name of the bucket and the name and byte range of the file. /// For use with the Larg File API. /// </summary> /// <param name="fileName"></param> /// <param name="bucketName"></param> /// <param name="startBytes"></param> /// <param name="endBytes"></param> /// <param name="cancelToken"></param> /// <returns></returns> public async Task <B2File> DownloadByName(string fileName, string bucketName, int startByte, int endByte, CancellationToken cancelToken = default(CancellationToken)) { // Are we searching by name or id? HttpRequestMessage request; request = FileDownloadRequestGenerators.DownloadByName(_options, bucketName, fileName, $"{startByte}-{endByte}"); // Send the download request var response = await _client.SendAsync(request, cancelToken); // Create B2File from response return(await ParseDownloadResponse(response)); }