[#40] Add FilePath field to ObjectBaseInfo

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-08-11 12:47:46 +03:00 committed by Kirillov Denis
parent 8917100857
commit 4fbd5a0c58
5 changed files with 29 additions and 6 deletions

View file

@ -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{}) {

View file

@ -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"`
}

View file

@ -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": {

View file

@ -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()
}
}

View file

@ -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