Skip to content

Commit

Permalink
Merge pull request #214 from nspcc-dev/change-expiration-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored May 30, 2024
2 parents fbdf29b + 1d5267a commit 5637dec
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 65 deletions.
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 paramIsPositive(s *string) bool {

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
}
if params.XNeofsEXPIRATIONTIMESTAMP != nil && *params.XNeofsEXPIRATIONTIMESTAMP != "" {
headers[ExpirationTimestampAttr] = *params.XNeofsEXPIRATIONTIMESTAMP
if params.XNeofsExpirationTimestamp != nil && *params.XNeofsExpirationTimestamp != "" {
headers[ExpirationTimestampAttr] = *params.XNeofsExpirationTimestamp
}
if params.XNeofsEXPIRATIONRFC3339 != nil && *params.XNeofsEXPIRATIONRFC3339 != "" {
headers[ExpirationRFC3339Attr] = *params.XNeofsEXPIRATIONRFC3339
if params.XNeofsExpirationRFC3339 != nil && *params.XNeofsExpirationRFC3339 != "" {
headers[ExpirationRFC3339Attr] = *params.XNeofsExpirationRFC3339
}
}
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

0 comments on commit 5637dec

Please sign in to comment.