|
|
|
@@ -3,6 +3,7 @@ package s3browser
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@@ -33,6 +34,13 @@ func copyMutation(ctx context.Context, src, dest string) (*File, error) {
|
|
|
|
return nil, fmt.Errorf("Failed to get s3Client from context")
|
|
|
|
return nil, fmt.Errorf("Failed to get s3Client from context")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if dest is a file or a dir
|
|
|
|
|
|
|
|
if strings.HasSuffix(dest, "/") {
|
|
|
|
|
|
|
|
// create new dest id
|
|
|
|
|
|
|
|
// TODO: What if a file with this id already exists?
|
|
|
|
|
|
|
|
dest += getFilenameFromID(src)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info, err := s3Client.CopyObject(ctx, minio.CopyDestOptions{
|
|
|
|
info, err := s3Client.CopyObject(ctx, minio.CopyDestOptions{
|
|
|
|
Bucket: bucketName,
|
|
|
|
Bucket: bucketName,
|
|
|
|
Object: dest,
|
|
|
|
Object: dest,
|
|
|
|
@@ -62,6 +70,13 @@ func moveMutation(ctx context.Context, src, dest string) (*File, error) {
|
|
|
|
return nil, fmt.Errorf("Failed to get s3Client from context")
|
|
|
|
return nil, fmt.Errorf("Failed to get s3Client from context")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if dest is a file or a dir
|
|
|
|
|
|
|
|
if strings.HasSuffix(dest, "/") {
|
|
|
|
|
|
|
|
// create new dest id
|
|
|
|
|
|
|
|
// TODO: What if a file with this id already exists?
|
|
|
|
|
|
|
|
dest += getFilenameFromID(src)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// There is no (spoon) move. Only copy and delete
|
|
|
|
// There is no (spoon) move. Only copy and delete
|
|
|
|
info, err := s3Client.CopyObject(ctx, minio.CopyDestOptions{
|
|
|
|
info, err := s3Client.CopyObject(ctx, minio.CopyDestOptions{
|
|
|
|
Bucket: bucketName,
|
|
|
|
Bucket: bucketName,
|
|
|
|
|