diff --git a/cmd/neofs-rest-gw/integration_test.go b/cmd/neofs-rest-gw/integration_test.go index 15e8862..de5e053 100644 --- a/cmd/neofs-rest-gw/integration_test.go +++ b/cmd/neofs-rest-gw/integration_test.go @@ -590,8 +590,10 @@ func restObjectDelete(ctx context.Context, t *testing.T, p *pool.Pool, owner *us func restObjectsSearch(ctx context.Context, t *testing.T, p *pool.Pool, owner *user.ID, cnrID cid.ID) { userKey, userValue := "User-Attribute", "user-attribute-value" objectName := "object-name" + filePath := "path/to/object/object-name" headers := map[string]string{ object.AttributeFileName: objectName, + "FilePath": filePath, userKey: userValue, } objID := createObject(ctx, t, p, owner, cnrID, headers, []byte("some content")) @@ -656,6 +658,7 @@ func restObjectsSearch(ctx context.Context, t *testing.T, p *pool.Pool, owner *u require.Equal(t, cnrID.EncodeToString(), *objBaseInfo.Address.ContainerID) require.Equal(t, objID.EncodeToString(), *objBaseInfo.Address.ObjectID) require.Equal(t, objectName, objBaseInfo.Name) + require.Equal(t, filePath, objBaseInfo.FilePath) } func doRequest(t *testing.T, httpClient *http.Client, request *http.Request, expectedCode int, model interface{}) { diff --git a/gen/models/object_base_info.go b/gen/models/object_base_info.go index 84ec32a..a375db7 100644 --- a/gen/models/object_base_info.go +++ b/gen/models/object_base_info.go @@ -15,7 +15,7 @@ import ( ) // ObjectBaseInfo Basic object information. -// Example: {"address":{"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"},"name":"/my/object/name"} +// Example: {"address":{"containerId":"5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv","objectId":"8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"},"filePath":"/my/object/name.txt","name":"name.txt"} // // swagger:model ObjectBaseInfo type ObjectBaseInfo struct { @@ -24,6 +24,9 @@ type ObjectBaseInfo struct { // Required: true Address *Address `json:"address"` + // file path + FilePath string `json:"filePath,omitempty"` + // name Name string `json:"name,omitempty"` } diff --git a/gen/restapi/embedded_spec.go b/gen/restapi/embedded_spec.go index 02d6f8a..62e2952 100644 --- a/gen/restapi/embedded_spec.go +++ b/gen/restapi/embedded_spec.go @@ -1119,6 +1119,9 @@ func init() { "address": { "$ref": "#/definitions/Address" }, + "filePath": { + "type": "string" + }, "name": { "type": "string" } @@ -1128,7 +1131,8 @@ func init() { "containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv", "objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd" }, - "name": "/my/object/name" + "filePath": "/my/object/name.txt", + "name": "name.txt" } }, "ObjectInfo": { @@ -2758,6 +2762,9 @@ func init() { "address": { "$ref": "#/definitions/Address" }, + "filePath": { + "type": "string" + }, "name": { "type": "string" } @@ -2767,7 +2774,8 @@ func init() { "containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv", "objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd" }, - "name": "/my/object/name" + "filePath": "/my/object/name.txt", + "name": "name.txt" } }, "ObjectInfo": { diff --git a/handlers/objects.go b/handlers/objects.go index 92e301c..fae273c 100644 --- a/handlers/objects.go +++ b/handlers/objects.go @@ -24,6 +24,10 @@ import ( "go.uber.org/zap" ) +const ( + attributeFilePath = "FilePath" +) + // PutObjects handler that uploads object to NeoFS. func (a *API) PutObjects(params operations.PutObjectParams, principal *models.Principal) middleware.Responder { errorResponse := operations.NewPutObjectBadRequest() @@ -307,9 +311,11 @@ func headObjectBaseInfo(ctx context.Context, p *pool.Pool, cnrID cid.ID, objID o } for _, attr := range objInfo.Attributes() { - if attr.Key() == object.AttributeFileName { + switch attr.Key() { + case object.AttributeFileName: resp.Name = attr.Value() - break + case attributeFilePath: + resp.FilePath = attr.Value() } } diff --git a/spec/rest.yaml b/spec/rest.yaml index e4f36e7..f464ef4 100644 --- a/spec/rest.yaml +++ b/spec/rest.yaml @@ -848,10 +848,13 @@ definitions: $ref: '#/definitions/Address' name: type: string + filePath: + type: string required: - address example: - name: "/my/object/name" + name: "name.txt" + filePath: "/my/object/name.txt" address: objectId: 8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd containerId: 5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv