public async Task <DownloadOperation> DownloadObjectAsync(Bucket bucket, string targetPath, DownloadOptions downloadOptions, bool immediateStart = true) { var downloadOptionsSWIG = downloadOptions.ToSWIG(); SWIG.DownloadResult downloadResult = await Task.Run(() => SWIG.storj_uplink.download_object(_access._project, bucket.Name, targetPath, downloadOptionsSWIG)); if (downloadResult.error != null && !string.IsNullOrEmpty(downloadResult.error.message)) { throw new ObjectNotFoundException(targetPath, downloadResult.error.message); } SWIG.ObjectResult objectResult = await Task.Run(() => SWIG.storj_uplink.download_info(downloadResult.download)); if (objectResult.error != null && !string.IsNullOrEmpty(objectResult.error.message)) { throw new ObjectNotFoundException(targetPath, objectResult.error.message); } DownloadOperation download = new DownloadOperation(downloadResult, objectResult.object_.system.content_length, targetPath); if (immediateStart) { download.StartDownloadAsync(); //Don't await it, otherwise it would "block" DownloadObjectAsync } SWIG.storj_uplink.free_object_result(objectResult); return(download); }
public async Task DeleteObjectAsync(Bucket bucket, string targetPath) { SWIG.ObjectResult objectResult = await Task.Run(() => SWIG.storj_uplink.delete_object(_access._project, bucket.Name, targetPath)); if (objectResult.error != null && !string.IsNullOrEmpty(objectResult.error.message)) { throw new ObjectNotFoundException(targetPath, objectResult.error.message); } SWIG.storj_uplink.free_object_result(objectResult); }