Example #1
0
        public async Task <IActionResult> Get(string fileKey)
        {
            try
            {
                var userKey           = _contextAccessor.UserKeyFromContext();
                var userCanAccessFile = await UserCanAccessFile(userKey, fileKey, _hiarcDatabase, AccessLevelGroup.ReadOnlyOrHigher);

                if (userCanAccessFile)
                {
                    var theFile = await _hiarcDatabase.GetFile(fileKey);

                    return(Ok(theFile));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status403Forbidden));
                }
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }