Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BlobApi
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
BlobApi
Commits
2d2e8549
Commit
2d2e8549
authored
2 years ago
by
Petar Hristov
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into 'master'
Release: Sprint/2022 14
See merge request
!71
parents
f579149a
4e83a139
No related branches found
No related tags found
1 merge request
!71
Release: Sprint/2022 14 :robot:
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Blob/Controllers/BlobController.cs
+0
-66
0 additions, 66 deletions
src/Blob/Controllers/BlobController.cs
with
0 additions
and
66 deletions
src/Blob/Controllers/BlobController.cs
+
0
−
66
View file @
2d2e8549
...
@@ -67,72 +67,6 @@ namespace Coscine.Api.Blob.Controllers
...
@@ -67,72 +67,6 @@ namespace Coscine.Api.Blob.Controllers
return
new
CustomUri
(
$"https://hdl.handle.net/
{
_prefix
}
/
{
resourceId
}
@path=
{
Uri
.
EscapeDataString
(
path
)}
"
);
return
new
CustomUri
(
$"https://hdl.handle.net/
{
_prefix
}
/
{
resourceId
}
@path=
{
Uri
.
EscapeDataString
(
path
)}
"
);
}
}
/// <summary>
/// This method returns the amount of allocated space for the given resource
/// </summary>
/// <param name="resourceId">Id of a resource</param>
/// <returns>Data, file count and byte size used or Status Code 400, 404, 401 or 500 </returns>
[
HttpGet
(
"[controller]/{resourceId}/quota"
)]
public
IActionResult
GetQuota
(
string
resourceId
)
{
if
(!
Guid
.
TryParse
(
resourceId
,
out
Guid
resourceGuid
))
{
return
BadRequest
(
$"
{
resourceId
}
is not a GUID."
);
}
var
user
=
_authenticator
.
GetUser
();
Resource
resource
;
try
{
resource
=
_resourceModel
.
GetById
(
resourceGuid
);
if
(
resource
==
null
)
{
return
NotFound
(
$"Could not find resource with id:
{
resourceId
}
"
);
}
}
catch
(
Exception
)
{
return
NotFound
(
$"Could not find resource with id:
{
resourceId
}
"
);
}
if
(
resource
.
Type
==
null
)
{
var
resourceTypeModel
=
new
ResourceTypeModel
();
resource
.
Type
=
resourceTypeModel
.
GetById
(
resource
.
TypeId
);
}
if
(
user
==
null
||
!
_resourceModel
.
HasAccess
(
user
,
resource
,
UserRoles
.
Owner
,
UserRoles
.
Member
))
{
return
BadRequest
(
"User does not have permission to the resource."
);
}
var
resourceTypeDefinition
=
ResourceTypeFactory
.
Instance
.
GetResourceType
(
resource
);
if
(
resourceTypeDefinition
==
null
)
{
return
BadRequest
(
$"No provider for: \"
{
resource
.
Type
.
DisplayName
}
\"."
);
}
var
resourceTypeInformation
=
resourceTypeDefinition
.
GetResourceTypeInformation
().
Result
;
if
(
resource
.
ResourceTypeOptionId
.
HasValue
&&
resourceTypeInformation
.
IsQuotaAvailable
)
{
try
{
var
totalFileSize
=
resourceTypeDefinition
.
GetResourceQuotaUsed
(
resourceId
).
Result
;
return
Ok
(
$"
{{
\
"data\": {{ \"usedSizeByte\": {totalFileSize} }}}}"
);
}
catch
(
Exception
e
)
{
_coscineLogger
.
Log
(
"Get Quota failed"
,
e
);
return
BadRequest
(
"Error in communication with the resource"
);
}
}
else
{
return
BadRequest
(
"The resource quota must be adjustable."
);
}
}
/// <summary>
/// <summary>
/// This method checks if the given file exists and returns it
/// This method checks if the given file exists and returns it
/// </summary>
/// </summary>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment