Skip to content
Snippets Groups Projects
Commit 7891acae authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Merge branch 'Sprint/2021-23' into 'master'

Sprint/2021 23

See merge request !48
parents f05ac4bc efaf2546
No related branches found
No related tags found
1 merge request!48Sprint/2021 23
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blob", "Blob\Blob.csproj", "{4F76105D-8FC5-403A-A822-9F306A028A76}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blob", "Blob\Blob.csproj", "{4F76105D-8FC5-403A-A822-9F306A028A76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
......@@ -24,5 +24,6 @@
<PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceTypeBase" Version="2.*-*" />
<PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
</ItemGroup>
</Project>
......@@ -144,6 +144,37 @@ namespace Coscine.Api.Blob.Controllers
/// <returns>File if file exists otherwise status code 204, 400, 401 or 404 </returns>
[HttpGet("[controller]/{resourceId}/{*path}")]
[DisableRequestSizeLimit]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> GetFileWithPath(string resourceId, string path)
{
return await GetFile(resourceId, path);
}
/// <summary>
/// This method checks if the given file exists and returns it
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path"> Path to the file </param>
/// <returns>File if file exists otherwise status code 204, 400, 401 or 404 </returns>
[HttpGet("[controller]/{resourceId}/")]
[DisableRequestSizeLimit]
public async Task<IActionResult> GetFileWithParameter(string resourceId, [System.Web.Http.FromUri] string path)
{
// Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/"))
{
path = path[1..];
}
return await GetFile(resourceId, path);
}
/// <summary>
/// This method checks if the given file exists and returns it
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path"> Path to the file </param>
/// <returns>File if file exists otherwise status code 204, 400, 401 or 404 </returns>
public async Task<IActionResult> GetFile(string resourceId, string path)
{
var user = _authenticator.GetUser();
......@@ -194,6 +225,40 @@ namespace Coscine.Api.Blob.Controllers
[DisableRequestSizeLimit]
[RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
[HttpPut("[controller]/{resourceId}/{*path}")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> UploadFileWithPath(string resourceId, string path, List<IFormFile> files)
{
return await UploadFile(resourceId, path, files);
}
/// <summary>
/// This method uploads a given File
/// </summary>
/// <param name="resourceId">Id of the resource </param>
/// <param name="path">Path to the file</param>
/// <param name="files">List of files.</param>
/// <returns>status code 204 if file is uploaded otherwise status code 400 or 403</returns>
[DisableRequestSizeLimit]
[RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
[HttpPut("[controller]/{resourceId}/")]
public async Task<IActionResult> UploadFileWithParameter(string resourceId, [System.Web.Http.FromUri] string path, List<IFormFile> files)
{
// Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/"))
{
path = path[1..];
}
return await UploadFile(resourceId, path, files);
}
/// <summary>
/// This method uploads a given File
/// </summary>
/// <param name="resourceId">Id of the resource </param>
/// <param name="path">Path to the file</param>
/// <param name="files">List of files.</param>
/// <returns>status code 204 if file is uploaded otherwise status code 400 or 403</returns>
public async Task<IActionResult> UploadFile(string resourceId, string path, List<IFormFile> files)
{
var user = _authenticator.GetUser();
......@@ -268,6 +333,36 @@ namespace Coscine.Api.Blob.Controllers
/// <param name="path">Path to the file</param>
/// <returns>status code 204 if deletion successful otherwise status code 400, 401 or 404 </returns>
[HttpDelete("[controller]/{resourceId}/{*path}")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> DeleteFileWithPath(string resourceId, string path)
{
return await DeleteFile(resourceId, path);
}
/// <summary>
/// This method deletes a given file
/// </summary>
/// <param name="resourceId">Id of the resource </param>
/// <param name="path">Path to the file</param>
/// <returns>status code 204 if deletion successful otherwise status code 400, 401 or 404 </returns>
[HttpDelete("[controller]/{resourceId}/")]
public async Task<IActionResult> DeleteFileWithParameter(string resourceId, [System.Web.Http.FromUri] string path)
{
// Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/"))
{
path = path[1..];
}
return await DeleteFile(resourceId, path);
}
/// <summary>
/// This method deletes a given file
/// </summary>
/// <param name="resourceId">Id of the resource </param>
/// <param name="path">Path to the file</param>
/// <returns>status code 204 if deletion successful otherwise status code 400, 401 or 404 </returns>
public async Task<IActionResult> DeleteFile(string resourceId, string path)
{
var user = _authenticator.GetUser();
......@@ -435,7 +530,7 @@ namespace Coscine.Api.Blob.Controllers
if (CoscineLoggerConfiguration.IsLogLevelActivated(LogType.Analytics))
{
_analyticsLogObject.Type = "Action";
_analyticsLogObject.FileId = resourceId + "/" + HttpUtility.UrlDecode(path)[1..];
_analyticsLogObject.FileId = resourceId + "/" + HttpUtility.UrlDecode(path);
_analyticsLogObject.ResourceId = resourceId;
_analyticsLogObject.ProjectId = _projectResourceModel.GetProjectForResource(new Guid(resourceId)).ToString();
_analyticsLogObject.RoleId = _projectRoleModel.GetGetUserRoleForProject(new Guid(_analyticsLogObject.ProjectId), user.Id).ToString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment