Exemple #1
0
        public async Task <int> UploadToCloud()
        {
            // Listing buckets.
            var bucketService = new BucketService(access);

            var buckets = await bucketService.ListBucketsAsync(new ListBucketsOptions());

            foreach (var b in buckets.Items)
            {
                Console.WriteLine(b.Name);
            }
            var restrictedBucketService = new BucketService(access);

            var newBucketName = "flureebucket";

            var bucket = await restrictedBucketService.GetBucketAsync(newBucketName);

            var fileObject = await GetFlureeSnapshot("1585578518736.avro");

            var uploadOperationRestricted = await objectService.UploadObjectAsync(bucket, fileObject.FileName, new UploadOptions(), fileObject.File, true);

            uploadOperationRestricted.UploadOperationProgressChanged += UploadOperationRestricted_UploadOperationProgressChanged;
            uploadOperationRestricted.UploadOperationEnded           += UploadOperationRestricted_UploadOperationEnded;
            await uploadOperationRestricted.StartUploadAsync();


            // Download a file from a bucket.

            var objects = await objectService.ListObjectsAsync(bucket, new ListObjectsOptions());

            foreach (var obj in objects.Items)
            {
                //work with the objects
                Console.WriteLine($"Found {obj.Key} {obj.SystemMetaData.Created}");


                //await objectService.DeleteObjectAsync(bucket, obj.Path);

//                var downloadSvc = await objectService.DownloadObjectAsync(bucket, obj.Path, false);
//                downloadSvc.DownloadOperationProgressChanged += DownloadOperation_DownloadOperationProgressChanged;
//                downloadSvc.DownloadOperationEnded += DownloadOperation_DownloadOperationEnded;
//                await downloadSvc.StartDownloadAsync();
            }


            return(0);
        }