diff --git a/internal/http/services/appprovider/appprovider.go b/internal/http/services/appprovider/appprovider.go index c06b808fc06..0bcba7b453c 100644 --- a/internal/http/services/appprovider/appprovider.go +++ b/internal/http/services/appprovider/appprovider.go @@ -49,6 +49,10 @@ import ( "github.com/rs/zerolog/log" ) +const ( + idDelimiter string = ":" +) + func init() { global.Register("appprovider", New) } @@ -199,14 +203,17 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } - // Stat created file and return its file id + // Stat the newly created file statRes, ocmderr, err := statRef(ctx, provider.Reference{Path: target}, client) if err != nil { log.Error().Err(err).Msg("error statting created file") ocmd.WriteError(w, r, ocmderr, "Created file not found", errtypes.NotFound("Created file not found")) return } - js, err := json.Marshal(map[string]interface{}{"file_id": statRes.Id}) + + // Base64-encode the fileid for the web to consume it + b64id := base64.StdEncoding.EncodeToString([]byte(statRes.Id.StorageId + idDelimiter + statRes.Id.OpaqueId)) + js, err := json.Marshal(map[string]interface{}{"file_id": b64id}) if err != nil { ocmd.WriteError(w, r, ocmd.APIErrorServerError, "error marshalling JSON response", err) return