GenerateBufferFromSeed() публичный Метод

public GenerateBufferFromSeed ( int size ) : byte[]
size int
Результат byte[]
Пример #1
0
        public async Task PutObject(Client client)
        {
            // generate random byte array
            RandomBufferGenerator generator = new RandomBufferGenerator(maxBufferSize);
            var data = generator.GenerateBufferFromSeed(maxBufferSize);

            // upload
            var createRsp = await client.PutObject(containerId, objectId, data);

            Assert.True(createRsp.IsSuccess);

            // exists
            var existsRsp = await client.HeadObject(containerId, objectId);

            Assert.True(existsRsp.IsSuccess && existsRsp.ContentLength == maxBufferSize);

            // get
            using (var getRsp = await client.GetObject(containerId, objectId))
            {
                Assert.True(getRsp.IsSuccess && getRsp.Stream != null);

                using (var ms = new MemoryStream())
                {
                    await getRsp.Stream.CopyToAsync(ms);

                    Assert.True(ms.Length == maxBufferSize);
                }
            }
        }
Пример #2
0
        public async Task PutChunkedObject(Client client)
        {
            var tasks = new List <Task>();

            // upload chunks
            for (var i = 0; i < Chunks; i++)
            {
                // generate random byte array
                RandomBufferGenerator generator = new RandomBufferGenerator(maxBufferSize);
                var data = generator.GenerateBufferFromSeed(maxBufferSize);

                var task = client.PutObjectChunk(containerId, chunkedObjectId, data, i);

                tasks.Add(task);
            }

            await Task.WhenAll(tasks);

            // upload manifest
            var manifestResp = await client.PutManifest(containerId, chunkedObjectId);

            Assert.True(manifestResp.IsSuccess);

            // exists
            var existsRsp = await client.HeadObject(containerId, chunkedObjectId);

            Assert.True(existsRsp.IsSuccess && existsRsp.ContentLength == maxBufferSize * Chunks);

            // get object
            using (var getRsp = await client.GetObject(containerId, chunkedObjectId))
            {
                Assert.True(getRsp.IsSuccess && getRsp.Stream != null);

                using (var ms = new MemoryStream())
                {
                    await getRsp.Stream.CopyToAsync(ms);

                    Assert.True(ms.Length == maxBufferSize * Chunks);
                }
            }

            // get chunk
            using (var chunkResp = await client.GetObjectRange(containerId, chunkedObjectId, 0, maxBufferSize - 1))
            {
                Assert.True(chunkResp.IsSuccess && chunkResp.Stream != null);

                using (var ms = new MemoryStream())
                {
                    await chunkResp.Stream.CopyToAsync(ms);

                    Assert.True(ms.Length == maxBufferSize);
                }
            }
        }
Пример #3
0
        private async Task UploadVideo(Client client)
        {
            var containerResponse = await client.PutContainer(containerId);

            if (containerResponse.IsSuccess)
            {
                // generate random byte array
                RandomBufferGenerator generator = new RandomBufferGenerator(fixture.MaxBufferSize);
                var data = generator.GenerateBufferFromSeed(fixture.MaxBufferSize);

                // upload
                var createRsp = await client.PutObject(containerId, videoId, data);
            }
        }