Пример #1
0
        public async Task <Uri> Put(Stream stream, TimeSpan?timeToLive = null, CancellationToken cancellationToken = new CancellationToken())
        {
            var name    = _fileNameCreator.Create();
            var address = _uriCreator.Create(name);

            var reference = _enchiladaFilesystemResolver.OpenFileReference(address.AbsoluteUri);

            using (var writeSteam = await reference.OpenWriteAsync()
                                    .ConfigureAwait(false))
            {
                await stream.CopyToAsync(writeSteam)
                .ConfigureAwait(false);

                await stream.FlushAsync(cancellationToken)
                .ConfigureAwait(false);
            }

            return(address);
        }
Пример #2
0
        protected async Task <TResponse> GetAsync <TResponse>(
            string uri,
            object queryParams = null,
            IReadOnlyCollection <KeyValuePair <string, string> > queryHeaders = null,
            HttpQuerySetting setting = null)
        {
            var fullUri = uriCreator.Create(GetApiEndpoint(), uri, queryParams);

            try
            {
                var response = await httpRequestExecutor.GetAsync(fullUri, AddDefaultHeaders(queryHeaders), setting ?? DefaultHttpQuerySetting()).ConfigureAwait(false);

                var result = responseParser.Parse <TResponse>(response);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }