示例#1
0
        /// <summary>
        /// Get file from database perform hierarchical search
        /// </summary>
        /// <param branchName="branchName">Branch where is stored file</param>
        /// <param path="path">file location in branch</param>
        /// <returns>A task of all files present in selected branch</returns>
        public async Task <MetafileDto> GetFile(string branchname, string path)
        {
            var file = await _dataBaseWrapper.GetFile(branchname, path);

            var fileUrl = await _fileStorage.GetDownloadUrl(file.BranchId + "/" + file.Id);

            var fildeDto = new MetafileDto {
                FileName = file.Filename, Path = file.Path, URL = fileUrl.AbsoluteUri, MD5Hash = file.MD5Hash, ContentMD5Hash = file.ContentMD5Hash
            };

            return(fildeDto);
        }
示例#2
0
        public async Task GetFile(RequestContext <IScenePeerClient> ctx)
        {
            var         branchName  = ctx.ReadObject <string>();
            var         path        = ctx.ReadObject <string>();
            MetafileDto metafileDto = null;

            try
            {
                metafileDto = await _assetsStorage.GetFile(branchName, path);
            }
            catch (BranchException ex)
            {
                _logger.Log(LogLevel.Warn, "AssetsStorageController", $"Branch not found: { branchName } ", ex.Message);
                throw new ClientException($"Branch Not Found:{ branchName }");
            }
            catch (FileException ex)
            {
                _logger.Log(LogLevel.Warn, "AssetsStorageController", $"File not found:  { path } ", ex.Message);
                throw new ClientException($"File not found :{ path }");
            }

            ctx.SendValue(metafileDto);
        }