private Task <object> GetFileContentAsync(IHttpRequest request)
        {
            var startTime = DateTime.Now;

            var method = $"{request.Method}::{request.Path}";

            Exception exception = null;

            try
            {
                string blobId = request.Parameters.id;

                if (!string.IsNullOrEmpty(blobId))
                {
                    var blobData = _blobStorage.GetBlobData(blobId);

                    if (blobData != null)
                    {
                        var fileResponse = new StreamHttpResponse(blobData.Data, blobData.Info.Type)
                        {
                            FileName         = blobData.Info.Name,
                            LastWriteTimeUtc = blobData.Info.Time
                        };

                        fileResponse.SetContentDispositionAttachment(request.Headers.UserAgent);

                        return(Task.FromResult <object>(fileResponse));
                    }
                }

                return(Task.FromResult <object>(HttpResponse.NotFound));
            }
            catch (Exception e)
            {
                exception = e;

                _log.Error(Resources.RequestProcessedWithException, new Dictionary <string, object> {
                    { "method", method }
                }, e);

                throw;
            }
            finally
            {
                _performanceLog.Log(method, startTime, exception);
            }
        }
        private Task <object> DownloadFile(IHttpRequest request)
        {
            string formString = request.Query.Form;

            dynamic form = null;

            if (!string.IsNullOrWhiteSpace(formString))
            {
                formString = Uri.UnescapeDataString(formString);
                form       = JsonObjectSerializer.Default.Deserialize(formString);
            }

            if (form != null)
            {
                string contentId = form.ContentId;

                if (!string.IsNullOrEmpty(contentId))
                {
                    var blobData = _blobStorage.GetBlobData(contentId);

                    if (blobData != null)
                    {
                        var fileResponse = new StreamHttpResponse(blobData.Data, blobData.Info.Type)
                        {
                            FileName         = blobData.Info.Name,
                            LastWriteTimeUtc = blobData.Info.Time
                        };

                        fileResponse.SetContentDispositionAttachment(request.Headers.UserAgent);

                        return(Task.FromResult <object>(fileResponse));
                    }
                }
            }

            return(Task.FromResult <object>(HttpResponse.NotFound));
        }