Beispiel #1
0
        public async Task CreateGetDestroyBlobs()
        {
            byte[] data1   = new byte[] { 0, 1, 2, 3, 4, 5 };
            byte[] data2   = new byte[] { 10, 11, 12, 13, 14, 15 };
            byte[] data3   = new byte[] { 20, 21, 22, 23, 24, 25 };
            var    dataSet = new byte[][] { data1, data2, data3 };

            var blob1 = await _session.CreateBlobAsync(data1);

            var blob2 = await _session.CreateBlobAsync(data2);

            var blob3 = await _session.CreateBlobAsync(data3);

            blob1.Should().BeGreaterThan(0);
            blob2.Should().BeGreaterThan(0);
            blob3.Should().BeGreaterThan(0);

            blob1.Should().NotBe(blob2);
            blob2.Should().NotBe(blob3);
            blob3.Should().NotBe(blob1);
            var blobIds = new ulong[] { blob1, blob2, blob3 };

            for (int i = 0; i < blobIds.Length; ++i)
            {
                var blob = await _session.GetBlobAsync(blobIds[i]);

                blob.Should().Equal(dataSet[i]);
            }

            await _session.DestroyBlobsAsync(blobIds);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the data for a given blob from R-Host. Saves the data to <paramref name="filePath"/>. This
        /// method adds the blob for clean up by default.
        /// </summary>
        /// <param name="blob">Blob from which the data is to be retrieved.</param>
        /// <param name="filePath">Path to the file where the retrieved data will be written.</param>
        /// <param name="doCleanUp">true to add blob upon transfer for cleanup on dispose, false to ignore it after transfer.</param>
        public async Task FetchFileAsync(IRBlobInfo blob, string filePath, bool doCleanUp = true)
        {
            var data = await _session.GetBlobAsync(blob.Id);

            _fs.FileWriteAllBytes(filePath, data);

            if (doCleanUp)
            {
                _cleanup.Add(blob);
            }
        }