From 5e68ce3e6df3c0c65a810ddff0acdf044808992d Mon Sep 17 00:00:00 2001 From: Theresia Rupprecht <rupprecht@itc.rwth-aachen.de> Date: Thu, 20 May 2021 09:46:12 +0000 Subject: [PATCH] New: exposingUrls coscine/issues#1527 --- README.md | 2 +- src/Tree/Controllers/TreeController.cs | 11 ++++++++--- src/Tree/Tree.csproj | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 22ab8db..7917e61 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ The project will be build and tested. * [Commit convention](docs/ESLintConvention.md) * [Everything possible with markup](docs/testdoc.md) -* [Adding NUnit tests](docs/nunit.md) \ No newline at end of file +* [Adding NUnit tests](docs/nunit.md) \ No newline at end of file diff --git a/src/Tree/Controllers/TreeController.cs b/src/Tree/Controllers/TreeController.cs index 9a8074d..47f7b38 100644 --- a/src/Tree/Controllers/TreeController.cs +++ b/src/Tree/Controllers/TreeController.cs @@ -22,6 +22,7 @@ using VDS.RDF.Parsing; using VDS.RDF.Writing; using Coscine.ResourceLoader; using Coscine.Configuration; +using Coscine.ResourceTypeBase; namespace Coscine.Api.Tree.Controllers { @@ -84,6 +85,7 @@ namespace Coscine.Api.Tree.Controllers [HttpGet("[controller]/{resourceId}/{*path}")] public async Task<IActionResult> GetMetadata(string resourceId, string path) { + var rawPath = path; path = $"/{path}"; if (path.Contains("%2F") || path.Contains("%2f")) { @@ -144,6 +146,8 @@ namespace Coscine.Api.Tree.Controllers Kind = x.Key[(x.Key.LastIndexOf(".") + 1)..], Provider = resource.Type.DisplayName }; + var resourceTypeOptions = _resourceModel.GetResourceTypeOptions(resource.Id); + var resourceTypeDefinition = ResourceTypeFactory.CreateResourceTypeObject(resource.Type.DisplayName, _configuration); var objectMetaInfoReturnObject = new ObjectMetaInfoReturnObject(objectMetaInfo, _blobApiLink, resource.Id.ToString()); var result = new JObject { @@ -156,7 +160,7 @@ namespace Coscine.Api.Tree.Controllers ["Provider"] = objectMetaInfoReturnObject.Provider, ["IsFolder"] = objectMetaInfoReturnObject.IsFolder, ["IsFile"] = objectMetaInfoReturnObject.IsFile, - ["Action"] = new JObject { + ["Action"] = new JObject { ["Delete"] = new JObject { ["Method"] = "DELETE", ["Url"] = objectMetaInfoReturnObject.DeleteLink @@ -164,12 +168,12 @@ namespace Coscine.Api.Tree.Controllers ["Download"] = new JObject { ["Method"] = "GET", - ["Url"] = objectMetaInfoReturnObject.DownloadLink + ["Url"] = resourceTypeDefinition?.GetEntryDownloadUrl(rawPath, null, resourceTypeOptions).Result.ToString() }, ["Upload"] = new JObject { ["Method"] = "PUT", - ["Url"] = objectMetaInfoReturnObject.UploadLink + ["Url"] = resourceTypeDefinition?.GetEntryStoreUrl(rawPath, null, resourceTypeOptions).Result.ToString() } } }; @@ -320,6 +324,7 @@ namespace Coscine.Api.Tree.Controllers return NoContent(); } + /// <summary> /// Checks the resource Id and the path /// </summary> diff --git a/src/Tree/Tree.csproj b/src/Tree/Tree.csproj index e50ed56..9898897 100644 --- a/src/Tree/Tree.csproj +++ b/src/Tree/Tree.csproj @@ -5,7 +5,7 @@ <AssemblyName>Coscine.Api.Tree</AssemblyName> <GenerateDocumentationFile>true</GenerateDocumentationFile> <TargetFramework>net5.0</TargetFramework> - <Version>2.1.0</Version> + <Version>2.1.1</Version> </PropertyGroup> <PropertyGroup> <Authors>RWTH Aachen University</Authors> -- GitLab