From 074e7cf71a3697d74830c13f7eda21a1e8e3d814 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 12 Apr 2024 08:57:34 +0800 Subject: [PATCH] chore: fix resource path --- server/route/api/v2/resource_service.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/route/api/v2/resource_service.go b/server/route/api/v2/resource_service.go index 59404a18..24f86df1 100644 --- a/server/route/api/v2/resource_service.go +++ b/server/route/api/v2/resource_service.go @@ -271,6 +271,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc internalPath = replacePathTemplate(internalPath, create.Filename) internalPath = filepath.ToSlash(internalPath) + // Ensure the directory exists. osPath := filepath.FromSlash(internalPath) if !filepath.IsAbs(osPath) { osPath = filepath.Join(s.Profile.Data, osPath) @@ -285,7 +286,8 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc } defer dst.Close() - if err := os.WriteFile(dir, create.Blob, 0644); err != nil { + // Write the blob to the file. + if err := os.WriteFile(osPath, create.Blob, 0644); err != nil { return errors.Wrap(err, "Failed to write file") } create.InternalPath = internalPath