working commit
This commit is contained in:
+16
-12
@@ -23,16 +23,18 @@ import (
|
||||
"mstore/pkg/auxuuid"
|
||||
)
|
||||
|
||||
// FileExists
|
||||
type FileExistsParams struct {
|
||||
// FileInfo
|
||||
type FileInfoParams struct {
|
||||
Filepath string
|
||||
Source string
|
||||
Dest string
|
||||
}
|
||||
type FileExistsResult struct {
|
||||
ContentType string
|
||||
ContentSize string
|
||||
ContentDigest string
|
||||
type FileInfoResult struct {
|
||||
ContentCollection string
|
||||
ContentName string
|
||||
ContentType string
|
||||
ContentSize string
|
||||
ContentDigest string
|
||||
}
|
||||
|
||||
func cleanFilepath(filename string) (string, error) {
|
||||
@@ -40,10 +42,10 @@ func cleanFilepath(filename string) (string, error) {
|
||||
return filepath.Clean(filename), nil
|
||||
}
|
||||
|
||||
func (oper *Operator) FileExists(ctx context.Context, param *FileExistsParams) (int, *FileExistsResult, error) {
|
||||
func (oper *Operator) FileInfo(ctx context.Context, param *FileInfoParams) (int, *FileInfoResult, error) {
|
||||
var err error
|
||||
code := http.StatusOK
|
||||
res := &FileExistsResult{}
|
||||
res := &FileInfoResult{}
|
||||
|
||||
xfilepath, err := cleanFilepath(param.Filepath)
|
||||
if err != nil {
|
||||
@@ -63,10 +65,12 @@ func (oper *Operator) FileExists(ctx context.Context, param *FileExistsParams) (
|
||||
code = http.StatusNotFound
|
||||
return code, res, err
|
||||
}
|
||||
res = &FileExistsResult{
|
||||
ContentSize: strconv.FormatInt(fileDescr.Size, 10),
|
||||
ContentType: fileDescr.Type,
|
||||
ContentDigest: fileDescr.Checksum,
|
||||
res = &FileInfoResult{
|
||||
ContentCollection: fileDescr.Collection,
|
||||
ContentName: fileDescr.Name,
|
||||
ContentSize: strconv.FormatInt(fileDescr.Size, 10),
|
||||
ContentType: fileDescr.Type,
|
||||
ContentDigest: fileDescr.Checksum,
|
||||
}
|
||||
return code, res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user