Exemple #1
0
        public async Task <DownloadOperation> DownloadObjectAsync(Bucket bucket, string targetPath, DownloadOptions downloadOptions, bool immediateStart = true)
        {
            using (var downloadOptionsSWIG = downloadOptions.ToSWIG())
            {
                using (SWIG.UplinkDownloadResult downloadResult = await Task.Run(() => SWIG.storj_uplink.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);
                    }

                    using (SWIG.UplinkObjectResult objectResult = await Task.Run(() => SWIG.storj_uplink.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
                        }
                        return(download);
                    }
                }
            }
        }
Exemple #2
0
        public async Task DeleteObjectAsync(Bucket bucket, string targetPath)
        {
            SWIG.UplinkObjectResult objectResult = await Task.Run(() => SWIG.storj_uplink.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.uplink_free_object_result(objectResult);
        }
 public async Task DeleteObjectAsync(Bucket bucket, string targetPath)
 {
     using (SWIG.UplinkObjectResult objectResult = await Task.Run(() => SWIG.storj_uplink.uplink_delete_object(_access._project, bucket.Name, targetPath)).ConfigureAwait(false))
     {
         if (objectResult.error != null && !string.IsNullOrEmpty(objectResult.error.message))
         {
             throw new ObjectNotFoundException(targetPath, objectResult.error.message);
         }
         if (objectResult.object_ == null)
         {
             throw new ObjectNotFoundException(targetPath);
         }
     }
 }