From ac9343c76c51445abb655b6b9807e5f2d424376f Mon Sep 17 00:00:00 2001 From: Marcel Nellesen <nellesen@itc.rwth-aachen.de> Date: Fri, 23 Apr 2021 10:29:54 +0200 Subject: [PATCH] Fix: Removed Download and Upload Url functions --- src/Blob/Controllers/BlobController.cs | 67 -------------------------- 1 file changed, 67 deletions(-) diff --git a/src/Blob/Controllers/BlobController.cs b/src/Blob/Controllers/BlobController.cs index 16be0eb..ef88a79 100644 --- a/src/Blob/Controllers/BlobController.cs +++ b/src/Blob/Controllers/BlobController.cs @@ -180,73 +180,6 @@ namespace Coscine.Api.Blob.Controllers } } - /// <summary> - /// This method returns the download url for a resource and path - /// </summary> - /// <param name="resourceId">Id of the resource</param> - /// <param name="path">Path to the to downloaded file</param> - /// <returns>Uri of the download url in the form of: "{ data: { url: url } }"</returns> - [HttpGet("[controller]/downloadUrl/{resourceId}/{*path}")] - public async Task<IActionResult> GetDownloadUrl(string resourceId, string path) - { - return await GetUrl(resourceId, path, - (resourceTypeDefinition, path, version, resourceTypeOptions) - => resourceTypeDefinition.GetEntryDownloadUrl(path, version, resourceTypeOptions)); - } - - /// <summary> - /// This method returns the upload url for a resource and path - /// </summary> - /// <param name="resourceId">Id of the resource</param> - /// <param name="path">Path to the to uploaded file</param> - /// <returns>Uri of the upload url in the form of: "{ data: { url: url } }"</returns> - [HttpGet("[controller]/uploadUrl/{resourceId}/{*path}")] - public async Task<IActionResult> GetUploadUrl(string resourceId, string path) - { - return await GetUrl(resourceId, path, - (resourceTypeDefinition, path, version, resourceTypeOptions) - => resourceTypeDefinition.GetEntryStoreUrl(path, version, resourceTypeOptions)); - } - - private async Task<IActionResult> GetUrl(string resourceId, string path, Func<ResourceTypeDefinition, string, string, Dictionary<string, string>, Task<Uri>> receiver) - { - var rawPath = path; - - var user = _authenticator.GetUser(); - path = $"/{path}"; - var checkPath = CheckPath(path); - if (checkPath != null) - { - return checkPath; - } - var checkResourceId = CheckResource(resourceId, out Resource resource); - if (checkResourceId != null) - { - return checkResourceId; - } - var checkUser = CheckUser(user, resource); - if (checkUser != null) - { - return checkUser; - } - - var resourceTypeOptions = _resourceModel.GetResourceTypeOptions(resource.Id); - var resourceTypeDefinition = ResourceTypeFactory.CreateResourceTypeObject(resource.Type.DisplayName, _configuration); - if (resourceTypeDefinition == null) - { - return BadRequest($"No provider for: \"{resource.Type.DisplayName}\"."); - } - - var entryUrl = await receiver(resourceTypeDefinition, rawPath, null, resourceTypeOptions); - if (entryUrl == null) - { - var hostUrl = await _configuration.GetStringAsync("coscine/local/api/additional/url"); - var apiPath = $"/coscine/api/{((System.Reflection.Assembly.GetEntryAssembly() != null) ? System.Reflection.Assembly.GetEntryAssembly().GetName().Name : System.Reflection.Assembly.GetExecutingAssembly().GetName().Name)}"; - entryUrl = new Uri($"{hostUrl}{apiPath}/Blob/{resourceId}/{rawPath}"); - } - return Ok($"{{ \"data\": {{ \"url\": \"{entryUrl}\" }} }}"); - } - /// <summary> /// This method uploads a given File /// </summary> -- GitLab