mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 16:41:35 -04:00
fix wrong pointer
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
committed by
Florian Schade
parent
0f5855cef4
commit
9e7f4487ad
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type SystemDataStorageClient struct {
|
||||
mds *metadata.Storage
|
||||
mds metadata.Storage
|
||||
}
|
||||
|
||||
func (s SystemDataStorageClient) SimpleDownload(ctx context.Context, userID, identifier string) ([]byte, error) {
|
||||
@@ -18,7 +18,7 @@ func (s SystemDataStorageClient) SimpleDownload(ctx context.Context, userID, ide
|
||||
}
|
||||
|
||||
func (s SystemDataStorageClient) SimpleUpload(ctx context.Context, userID, identifier string, content []byte) error {
|
||||
fmt.Println(content)
|
||||
s.mds.SimpleUpload(ctx, fmt.Sprintf("%s/%s", userID, identifier), content)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -43,15 +43,20 @@ func (s SystemDataStorageClient) Init(ctx context.Context, userID, identifier st
|
||||
}
|
||||
|
||||
// NewProfileStorageClient creates a new ProfileStorageClient
|
||||
func NewSystemStorageClient(nameSpace string,
|
||||
func NewSystemStorageClient(scope, nameSpace string,
|
||||
logger *log.Logger,
|
||||
gatewayAddress, storageAddress, systemUserID, systemUserIDP, systemUserAPIKey string) SystemDataStorageClient {
|
||||
|
||||
// scope: the scope the data should be persistet in (e.g. user)
|
||||
// namespace: the namespace the data should be persistet in (e.g. profilephoto)
|
||||
// results in the following path: /<scope>/*/<namespace>/*
|
||||
|
||||
sdsci := SystemDataStorageClient{}
|
||||
logger.Debug().Msg("NewSystemStorageClient called")
|
||||
sdsc, err := metadata.NewCS3Storage(gatewayAddress, storageAddress, systemUserID, systemUserIDP, systemUserAPIKey)
|
||||
if err != nil {
|
||||
logger.Fatal().Err(err).Msg("could not create profile storage client")
|
||||
}
|
||||
sdsci.mds = &sdsc
|
||||
sdsci.mds = sdsc
|
||||
return sdsci
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
var (
|
||||
namespace = "profilephoto"
|
||||
scope = "user"
|
||||
identifier = "profilephoto"
|
||||
)
|
||||
|
||||
@@ -90,6 +91,7 @@ func (g Graph) UpdatePhoto(w http.ResponseWriter, r *http.Request) {
|
||||
func (g Graph) updatePhoto(w http.ResponseWriter, r *http.Request, u *userpb.UserId) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Debug().Msg("UpdatePhoto called")
|
||||
g.getSystemStorageClient()
|
||||
content, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Msg("could not read body")
|
||||
@@ -101,7 +103,6 @@ func (g Graph) updatePhoto(w http.ResponseWriter, r *http.Request, u *userpb.Use
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "empty body")
|
||||
return
|
||||
}
|
||||
g.getSystemStorageClient()
|
||||
err = g.sdsc.SimpleUpload(r.Context(), u.GetOpaqueId(), identifier, content)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Msg("could not upload photo")
|
||||
@@ -115,6 +116,7 @@ func (g Graph) updatePhoto(w http.ResponseWriter, r *http.Request, u *userpb.Use
|
||||
func (g Graph) getSystemStorageClient() systemstorageclient.SystemDataStorageClient {
|
||||
// TODO: this needs a check if the client is already initialized and if not, initialize it
|
||||
g.sdsc = systemstorageclient.NewSystemStorageClient(
|
||||
scope,
|
||||
namespace,
|
||||
g.logger,
|
||||
g.config.SystemStorageClient.GatewayAddress,
|
||||
|
||||
Reference in New Issue
Block a user