diff --git a/README.md b/README.md index 22ab8dbd76799aec595e1aa67797c0b846e7c9f7..7917e61fc1e702fbfd6e19f71ea3a5af37b27083 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 9a8074d5ea1738bbb1a6578696d7155c4b3dfbef..47f7b3878fb250d81c362b885d791ff92f03f717 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 e50ed560985dd3c8a79520e8db54792b591c0b5f..9898897fe94a75a0d05258a8a5559951d4cbd4bc 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>