diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala index 9d74c5e028..066bcb7d2d 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala @@ -713,7 +713,7 @@ object ValueContentV2 { for { sipiService <- ZIO.service[SipiService] assetId <- ZIO - .fromEither(AssetId.from(filename.substring(0, filename.indexOf('.')))) + .fromEither(AssetId.fromFilename(filename)) .mapError(msg => BadRequestException(s"Invalid value for 'fileValueHasFilename': $msg")) meta <- sipiService.getFileMetadataFromDspIngest(shortcode, assetId).mapError { case NotFoundException(_) => diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala index 28ce82bdfa..73ff481e28 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/api/model/MaintenanceRequests.scala @@ -21,7 +21,14 @@ import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode object MaintenanceRequests { type AssetId = String Refined MatchesRegex["^[a-zA-Z0-9-_]{4,}$"] - object AssetId extends RefinedTypeOps[AssetId, String] + object AssetId extends RefinedTypeOps[AssetId, String] { + + def fromFilename(filename: String): Either[String, AssetId] = { + val withoutFileExtension = + if filename.contains(".") then filename.substring(0, filename.indexOf('.')) else filename + AssetId.from(withoutFileExtension) + } + } final case class Dimensions(width: Int Refined Positive, height: Int Refined Positive)