Skip to content
Snippets Groups Projects
Commit 206816f5 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'product/1472-exposingUrls' into 'Sprint/2021-09'

Product/1472 exposing urls

See merge request !32
parents f47bba35 38ad362e
Branches
No related tags found
2 merge requests!32Product/1472 exposing urls,!31Sprint/2021 09
...@@ -22,6 +22,7 @@ using VDS.RDF.Parsing; ...@@ -22,6 +22,7 @@ using VDS.RDF.Parsing;
using VDS.RDF.Writing; using VDS.RDF.Writing;
using Coscine.ResourceLoader; using Coscine.ResourceLoader;
using Coscine.Configuration; using Coscine.Configuration;
using Coscine.ResourceTypeBase;
namespace Coscine.Api.Tree.Controllers namespace Coscine.Api.Tree.Controllers
{ {
...@@ -84,6 +85,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -84,6 +85,7 @@ namespace Coscine.Api.Tree.Controllers
[HttpGet("[controller]/{resourceId}/{*path}")] [HttpGet("[controller]/{resourceId}/{*path}")]
public async Task<IActionResult> GetMetadata(string resourceId, string path) public async Task<IActionResult> GetMetadata(string resourceId, string path)
{ {
var rawPath = path;
path = $"/{path}"; path = $"/{path}";
if (path.Contains("%2F") || path.Contains("%2f")) if (path.Contains("%2F") || path.Contains("%2f"))
{ {
...@@ -144,6 +146,8 @@ namespace Coscine.Api.Tree.Controllers ...@@ -144,6 +146,8 @@ namespace Coscine.Api.Tree.Controllers
Kind = x.Key[(x.Key.LastIndexOf(".") + 1)..], Kind = x.Key[(x.Key.LastIndexOf(".") + 1)..],
Provider = resource.Type.DisplayName 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 objectMetaInfoReturnObject = new ObjectMetaInfoReturnObject(objectMetaInfo, _blobApiLink, resource.Id.ToString());
var result = new JObject var result = new JObject
{ {
...@@ -164,12 +168,12 @@ namespace Coscine.Api.Tree.Controllers ...@@ -164,12 +168,12 @@ namespace Coscine.Api.Tree.Controllers
["Download"] = new JObject ["Download"] = new JObject
{ {
["Method"] = "GET", ["Method"] = "GET",
["Url"] = objectMetaInfoReturnObject.DownloadLink ["Url"] = resourceTypeDefinition?.GetEntryDownloadUrl(rawPath, null, resourceTypeOptions).Result.ToString()
}, },
["Upload"] = new JObject ["Upload"] = new JObject
{ {
["Method"] = "PUT", ["Method"] = "PUT",
["Url"] = objectMetaInfoReturnObject.UploadLink ["Url"] = resourceTypeDefinition?.GetEntryStoreUrl(rawPath, null, resourceTypeOptions).Result.ToString()
} }
} }
}; };
...@@ -320,6 +324,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -320,6 +324,7 @@ namespace Coscine.Api.Tree.Controllers
return NoContent(); return NoContent();
} }
/// <summary> /// <summary>
/// Checks the resource Id and the path /// Checks the resource Id and the path
/// </summary> /// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment