コード例 #1
0
        public async Task <IActionResult> Download(string id)
        {
            try
            {
                Guid binaryObjectId;
                Guid.TryParse(id, out binaryObjectId);

                BinaryObject binaryObject = repository.GetOne(binaryObjectId);

                if (binaryObject == null || binaryObjectId == null || binaryObjectId == Guid.Empty)
                {
                    ModelState.AddModelError("Binary Object Export", "No binary object or binary object file found");
                    return(BadRequest(ModelState));
                }

                var fileObject = binaryObjectManager.Download(binaryObjectId.ToString());

                return(File(fileObject?.Result?.BlobStream, fileObject?.Result?.ContentType, fileObject?.Result?.Name));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }