Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import org.springframework.web.multipart.MultipartFile
import software.amazon.awssdk.services.s3.S3Client
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request

private const val WORKSPACE_FILES_BASE_FOLDER = "workspace-files"

@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@Suppress("TooManyFunctions")
Expand Down Expand Up @@ -240,7 +242,9 @@ internal class WorkspaceServiceImpl(
fileName)
return InputStreamResource(
s3Template
.download(csmPlatformProperties.s3.bucketName, "$organizationId/$workspaceId/$fileName")
.download(
csmPlatformProperties.s3.bucketName,
"$organizationId/$workspaceId/$WORKSPACE_FILES_BASE_FOLDER/$fileName")
.inputStream)
}

Expand Down Expand Up @@ -280,7 +284,8 @@ internal class WorkspaceServiceImpl(
fileRelativeDestinationBuilder.append(file.originalFilename)
}
}
val objectKey = "$organizationId/$workspaceId/$fileRelativeDestinationBuilder"
val objectKey =
"$organizationId/$workspaceId/$WORKSPACE_FILES_BASE_FOLDER/$fileRelativeDestinationBuilder"

if (!overwrite && s3Template.objectExists(csmPlatformProperties.s3.bucketName, objectKey)) {
throw IllegalArgumentException(
Expand Down Expand Up @@ -319,7 +324,7 @@ internal class WorkspaceServiceImpl(
}

private fun getWorkspaceFiles(organizationId: String, workspaceId: String): List<WorkspaceFile> {
val prefix = "${organizationId}/${workspaceId}/"
val prefix = "${organizationId}/${workspaceId}/$WORKSPACE_FILES_BASE_FOLDER/"
val listObjectsRequest =
ListObjectsV2Request.builder()
.bucket(csmPlatformProperties.s3.bucketName)
Expand Down Expand Up @@ -347,7 +352,8 @@ internal class WorkspaceServiceImpl(
fileName)

s3Template.deleteObject(
csmPlatformProperties.s3.bucketName, "$organizationId/${workspace.id}/$fileName")
csmPlatformProperties.s3.bucketName,
"$organizationId/${workspace.id}/$WORKSPACE_FILES_BASE_FOLDER/$fileName")
}

override fun deleteAllS3WorkspaceObjects(organizationId: String, workspace: Workspace) {
Expand Down
Loading