diff --git a/src/Blob/Controllers/BlobController.cs b/src/Blob/Controllers/BlobController.cs index 16be0eb9a2b40e3842d3240ec48028221102b7b5..ef88a791b449dc18a04ed868caeba7651539afd7 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>