Skip to content
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

Change header names in the new upload request #214

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/migration-new-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ like "FilePath", "FileName", and "Timestamp", can be passed in a JSON-formatted
key-value map. Thanks to the JSON format of this header, we no longer face
issues with the case-insensitivity of the gateway and the case-sensitivity of
NeoFS. All attributes are passed directly to NeoFS. Additionally,
`X-Neofs-EXPIRATION*` headers are available to set object expiration. Learn
`X-Neofs-Expiration-*` headers are available to set object expiration. Learn
more in the Swagger documentation (`/v1/docs`).

Notice that while the `/upload` API required you to create a multipart/form-data
Expand Down
96 changes: 48 additions & 48 deletions handlers/apiserver/rest-server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions handlers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@

func addExpirationHeaders(headers map[string]string, params apiserver.NewUploadContainerObjectParams) {
// Add non-empty string pointer values to the map
if params.XNeofsEXPIRATIONDURATION != nil && *params.XNeofsEXPIRATIONDURATION != "" {
headers[ExpirationDurationAttr] = *params.XNeofsEXPIRATIONDURATION
if params.XNeofsExpirationDuration != nil && *params.XNeofsExpirationDuration != "" {
headers[ExpirationDurationAttr] = *params.XNeofsExpirationDuration

Check warning on line 394 in handlers/util.go

View check run for this annotation

Codecov / codecov/patch

handlers/util.go#L393-L394

Added lines #L393 - L394 were not covered by tests
}
if params.XNeofsEXPIRATIONTIMESTAMP != nil && *params.XNeofsEXPIRATIONTIMESTAMP != "" {
headers[ExpirationTimestampAttr] = *params.XNeofsEXPIRATIONTIMESTAMP
if params.XNeofsExpirationTimestamp != nil && *params.XNeofsExpirationTimestamp != "" {
headers[ExpirationTimestampAttr] = *params.XNeofsExpirationTimestamp

Check warning on line 397 in handlers/util.go

View check run for this annotation

Codecov / codecov/patch

handlers/util.go#L396-L397

Added lines #L396 - L397 were not covered by tests
}
if params.XNeofsEXPIRATIONRFC3339 != nil && *params.XNeofsEXPIRATIONRFC3339 != "" {
headers[ExpirationRFC3339Attr] = *params.XNeofsEXPIRATIONRFC3339
if params.XNeofsExpirationRFC3339 != nil && *params.XNeofsExpirationRFC3339 != "" {
headers[ExpirationRFC3339Attr] = *params.XNeofsExpirationRFC3339

Check warning on line 400 in handlers/util.go

View check run for this annotation

Codecov / codecov/patch

handlers/util.go#L399-L400

Added lines #L399 - L400 were not covered by tests
}
}
12 changes: 6 additions & 6 deletions handlers/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,19 @@ func Test_parseAndFilterAttributes(t *testing.T) {
str1 := `{
"skip empty":"",
"":"skip empty",
"__NEOFS__EXPIRATION_DURATION":"1000s",
"__NEOFS__EXPIRATION_EPOCH":"1000",
"file-N%me":"simple %bj filename",
"writer":"Leo Tolstoy",
"Chapter1":"pe@ce",
"chapter2":"war"}`

emptyMap := make(map[string]string)
map1 := map[string]string{
"__NEOFS__EXPIRATION_DURATION": "1000s",
"file-N%me": "simple %bj filename",
"writer": "Leo Tolstoy",
"Chapter1": "pe@ce",
"chapter2": "war",
"__NEOFS__EXPIRATION_EPOCH": "1000",
"file-N%me": "simple %bj filename",
"writer": "Leo Tolstoy",
"Chapter1": "pe@ce",
"chapter2": "war",
}

tests := []struct {
Expand Down
8 changes: 4 additions & 4 deletions spec/rest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -933,10 +933,10 @@ paths:
- `__NEOFS__EXPIRATION_EPOCH` - specifies the expiration epoch used by NeoFS.
This attribute should be used if you are familiar with the NeoFS epoch system.
More information can be found here: [NeoFS Specifications](https://github.com/nspcc-dev/neofs-spec/blob/master/01-arch/01-netmap.md).
Instead of this attribute you can use one of `X-Neofs-*` headers below.
Instead of this attribute you can use one of `X-Neofs-Expiration-*` headers below.
schema:
type: string
- name: X-Neofs-EXPIRATION_RFC3339
- name: X-Neofs-Expiration-RFC3339
in: header
description: |
Specifies the expiration time in RFC3339 format. Examples:
Expand All @@ -946,13 +946,13 @@ paths:
attribute of the created object.
schema:
type: string
- name: X-Neofs-EXPIRATION_TIMESTAMP
- name: X-Neofs-Expiration-Timestamp
in: header
description: Specifies the exact timestamp of object expiration. It will be rounded
to the next epoch and stored in the `__NEOFS__EXPIRATION_EPOCH` attribute of the created object.
schema:
type: string
- name: X-Neofs-EXPIRATION_DURATION
- name: X-Neofs-Expiration-Duration
in: header
description: |
Specifies the duration until object expiration in Go's duration format. Examples:
Expand Down
Loading