diff --git a/cmd/storage.go b/cmd/storage.go index fefdc87f5..c161c4845 100644 --- a/cmd/storage.go +++ b/cmd/storage.go @@ -35,7 +35,7 @@ var ( cpCmd = &cobra.Command{ Use: "cp ", - Example: `cp readme.md ss:///bucket + Example: `cp readme.md ss:///bucket/readme.md cp -r docs ss:///bucket/docs cp -r ss:///bucket/docs . `, diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index 328e40c15..eaf972e9c 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -108,7 +108,8 @@ func UploadStorageObjectAll(ctx context.Context, projectRef, remotePath, localPa dstPath := remotePath // Copying single file if relPath == "." { - if IsDir(dstPath) || (dirExists && !fileExists) { + _, prefix := storage.SplitBucketPrefix(dstPath) + if IsDir(prefix) || (dirExists && !fileExists) { dstPath = path.Join(dstPath, info.Name()) } } else { @@ -132,6 +133,6 @@ func UploadStorageObjectAll(ctx context.Context, projectRef, remotePath, localPa }) } -func IsDir(objectPath string) bool { - return len(objectPath) == 0 || strings.HasSuffix(objectPath, "/") +func IsDir(objectPrefix string) bool { + return len(objectPrefix) == 0 || strings.HasSuffix(objectPrefix, "/") }