forked from TrueCloudLab/frostfs-rest-gw
[#40] Add FilePath field to ObjectBaseInfo
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
8917100857
commit
4fbd5a0c58
5 changed files with 29 additions and 6 deletions
|
@ -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) {
|
func restObjectsSearch(ctx context.Context, t *testing.T, p *pool.Pool, owner *user.ID, cnrID cid.ID) {
|
||||||
userKey, userValue := "User-Attribute", "user-attribute-value"
|
userKey, userValue := "User-Attribute", "user-attribute-value"
|
||||||
objectName := "object-name"
|
objectName := "object-name"
|
||||||
|
filePath := "path/to/object/object-name"
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
object.AttributeFileName: objectName,
|
object.AttributeFileName: objectName,
|
||||||
|
"FilePath": filePath,
|
||||||
userKey: userValue,
|
userKey: userValue,
|
||||||
}
|
}
|
||||||
objID := createObject(ctx, t, p, owner, cnrID, headers, []byte("some content"))
|
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, cnrID.EncodeToString(), *objBaseInfo.Address.ContainerID)
|
||||||
require.Equal(t, objID.EncodeToString(), *objBaseInfo.Address.ObjectID)
|
require.Equal(t, objID.EncodeToString(), *objBaseInfo.Address.ObjectID)
|
||||||
require.Equal(t, objectName, objBaseInfo.Name)
|
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{}) {
|
func doRequest(t *testing.T, httpClient *http.Client, request *http.Request, expectedCode int, model interface{}) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectBaseInfo Basic object information.
|
// 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
|
// swagger:model ObjectBaseInfo
|
||||||
type ObjectBaseInfo struct {
|
type ObjectBaseInfo struct {
|
||||||
|
@ -24,6 +24,9 @@ type ObjectBaseInfo struct {
|
||||||
// Required: true
|
// Required: true
|
||||||
Address *Address `json:"address"`
|
Address *Address `json:"address"`
|
||||||
|
|
||||||
|
// file path
|
||||||
|
FilePath string `json:"filePath,omitempty"`
|
||||||
|
|
||||||
// name
|
// name
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1119,6 +1119,9 @@ func init() {
|
||||||
"address": {
|
"address": {
|
||||||
"$ref": "#/definitions/Address"
|
"$ref": "#/definitions/Address"
|
||||||
},
|
},
|
||||||
|
"filePath": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -1128,7 +1131,8 @@ func init() {
|
||||||
"containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv",
|
"containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv",
|
||||||
"objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"
|
"objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"
|
||||||
},
|
},
|
||||||
"name": "/my/object/name"
|
"filePath": "/my/object/name.txt",
|
||||||
|
"name": "name.txt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ObjectInfo": {
|
"ObjectInfo": {
|
||||||
|
@ -2758,6 +2762,9 @@ func init() {
|
||||||
"address": {
|
"address": {
|
||||||
"$ref": "#/definitions/Address"
|
"$ref": "#/definitions/Address"
|
||||||
},
|
},
|
||||||
|
"filePath": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -2767,7 +2774,8 @@ func init() {
|
||||||
"containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv",
|
"containerId": "5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv",
|
||||||
"objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"
|
"objectId": "8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd"
|
||||||
},
|
},
|
||||||
"name": "/my/object/name"
|
"filePath": "/my/object/name.txt",
|
||||||
|
"name": "name.txt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ObjectInfo": {
|
"ObjectInfo": {
|
||||||
|
|
|
@ -24,6 +24,10 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
attributeFilePath = "FilePath"
|
||||||
|
)
|
||||||
|
|
||||||
// PutObjects handler that uploads object to NeoFS.
|
// PutObjects handler that uploads object to NeoFS.
|
||||||
func (a *API) PutObjects(params operations.PutObjectParams, principal *models.Principal) middleware.Responder {
|
func (a *API) PutObjects(params operations.PutObjectParams, principal *models.Principal) middleware.Responder {
|
||||||
errorResponse := operations.NewPutObjectBadRequest()
|
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() {
|
for _, attr := range objInfo.Attributes() {
|
||||||
if attr.Key() == object.AttributeFileName {
|
switch attr.Key() {
|
||||||
|
case object.AttributeFileName:
|
||||||
resp.Name = attr.Value()
|
resp.Name = attr.Value()
|
||||||
break
|
case attributeFilePath:
|
||||||
|
resp.FilePath = attr.Value()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -848,10 +848,13 @@ definitions:
|
||||||
$ref: '#/definitions/Address'
|
$ref: '#/definitions/Address'
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
filePath:
|
||||||
|
type: string
|
||||||
required:
|
required:
|
||||||
- address
|
- address
|
||||||
example:
|
example:
|
||||||
name: "/my/object/name"
|
name: "name.txt"
|
||||||
|
filePath: "/my/object/name.txt"
|
||||||
address:
|
address:
|
||||||
objectId: 8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd
|
objectId: 8N3o7Dtr6T1xteCt6eRwhpmJ7JhME58Hyu1dvaswuTDd
|
||||||
containerId: 5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv
|
containerId: 5HZTn5qkRnmgSz9gSrw22CEdPPk6nQhkwf2Mgzyvkikv
|
||||||
|
|
Loading…
Reference in a new issue