-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new upload and edit download requests #206
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #206 +/- ##
==========================================
- Coverage 22.14% 22.13% -0.02%
==========================================
Files 16 17 +1
Lines 2894 3293 +399
==========================================
+ Hits 641 729 +88
- Misses 2137 2431 +294
- Partials 116 133 +17 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in general this approach should be OK for us. S3 goes via PutObjectTagging
with XML-encoded data, but we can't have a separate request since objects are immutable. Caveats:
- data with embedded newlines, it can't be handled in headers easily (requires safe encoding), special characters can be a problem too
- some data comes from headers and some from these attributes, we need to lay down the rules explicitly on how they interact
- well-known attributes can be handled via well-known headers
spec/rest.yaml
Outdated
type: string | ||
requestBody: | ||
content: | ||
multipart/form-data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's think if we need it to be a multipart/form-data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? What other options do we have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the object can be uploaded directly to the body request.
a11b6e2
to
fa56453
Compare
spec/rest.yaml
Outdated
- "2024-12-31T23:59:59Z" represents the last moment of 2024 in UTC. | ||
- "2024-12-31T15:59:59-08:00" represents 3:59 PM on December 31, 2024, Pacific Time. | ||
- `__NEOFS__EXPIRATION_TIMESTAMP` - specifies the exact timestamp of expiration. | ||
- `__NEOFS__EXPIRATION_DURATION` - specifies the duration until expiration in Go's duration format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where this comes from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was here for ages:
neofs-rest-gw/handlers/util.go
Line 37 in f024e79
ExpirationDurationAttr = SystemAttributePrefix + "EXPIRATION_DURATION" |
neofs-rest-gw/handlers/util.go
Line 114 in f024e79
func prepareExpirationHeader(headers map[string]string, epochDurations *epochDurations, now time.Time) error { |
spec/rest.yaml
Outdated
Examples: | ||
- "2024-12-31T23:59:59Z" represents the last moment of 2024 in UTC. | ||
- "2024-12-31T15:59:59-08:00" represents 3:59 PM on December 31, 2024, Pacific Time. | ||
- `__NEOFS__EXPIRATION_TIMESTAMP` - specifies the exact timestamp of expiration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered in the other thread.
spec/rest.yaml
Outdated
All attributes are in a JSON-formatted map of key-value pairs, where the key is the | ||
attribute name and the value is the attribute value. | ||
You can also use one of these special attributes: | ||
- `__NEOFS__EXPIRATION_RFC3339` - specifies the expiration time in RFC3339 format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't be written like this, they're not a real object attributes, API knows nothing about them. We can emulate some of them for user convenience, but we better do this via real HTTP headers, leave JSON for real attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we will use the following headers for the three attributes: X-Neofs-EXPIRATION_DURATION
, X-Neofs-EXPIRATION_TIMESTAMP
, X-Neofs-EXPIRATION_RFC3339
as they are in the old GET request. Okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
handlers/objects.go
Outdated
@@ -434,7 +436,7 @@ func (a *RestAPI) getByAddress(ctx echo.Context, addr oid.Address, downloadParam | |||
|
|||
var ( | |||
payloadSize = header.PayloadSize() | |||
contentType = a.setAttributes(ctx, payloadSize, addr.Container().String(), addr.Object().String(), header, downloadParam) | |||
contentType = a.setAttributes(ctx, payloadSize, addr.Container().String(), addr.Object().String(), header, downloadParam, jsonParam) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this function may require a small argument refactoring. To many parameters, we should consider moving them in struct. But maybe in different issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed using a structure.
handlers/objects.go
Outdated
var useJSON bool | ||
if jsonParam != nil && paramIsPositive(*jsonParam) { | ||
useJSON = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may simplify a bit
useJSON := jsonParam != nil && paramIsPositive(*jsonParam)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tnx, fixed.
handlers/util.go
Outdated
func paramIsPositive(s string) bool { | ||
switch s { | ||
case "1", "t", "T", "true", "TRUE", "True", "y", "yes", "Y", "YES", "Yes": | ||
return true | ||
} | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All usage of the func is working with the pointer. I consider it makes sense to replace the parameter s string
to s *string
and handle nil inside this function. Yes, it can affect the tests, but simplify the code in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
bde50cf
to
a7b4cd7
Compare
Signed-off-by: Tatiana Nesterenko <[email protected]>
Add a new POST request `/objects/{cId}` that accepts the `X-Attributes` header. Also, new GET and HEAD requests are added for object downloading: `/objects/{containerId}/by_id/{objectId}` and `/objects/{containerId}/by_attribute/{attrKey}/{attrVal}`. Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
Signed-off-by: Tatiana Nesterenko <[email protected]>
a7b4cd7
to
3747724
Compare
After smallhive's review, I only rebased the branch on the current master. |
Close #168.