Skip to content

Commit 6821a68

Browse files
committed
Update ResourceScanner to use MultipartFile instead of Resource
Replaced `Resource` with `MultipartFile` in the `scanMimeTypes` method, ensuring compatibility with file upload handling in Spring applications. Adjusted filename retrieval accordingly.
1 parent 47f3da4 commit 6821a68

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/kotlin/com/cosmotech/api/utils/ResourceScanner.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import org.apache.tika.metadata.Metadata
1212
import org.apache.tika.metadata.TikaCoreProperties
1313
import org.slf4j.Logger
1414
import org.slf4j.LoggerFactory
15-
import org.springframework.core.io.Resource
1615
import org.springframework.stereotype.Component
16+
import org.springframework.web.multipart.MultipartFile
1717

1818
private const val ZIP_MIME_TYPE = "zip"
1919
private const val ENTRY_NAME_UNKNOWN = "Unknown"
@@ -22,10 +22,10 @@ private const val ENTRY_NAME_UNKNOWN = "Unknown"
2222
class ResourceScanner {
2323
private val logger: Logger = LoggerFactory.getLogger(this::class.java)
2424

25-
fun scanMimeTypes(file: Resource, authorizedMimeTypes: List<String>) {
25+
fun scanMimeTypes(file: MultipartFile, authorizedMimeTypes: List<String>) {
2626
val tika = TikaConfig()
2727
val inputStream = file.inputStream
28-
val name = file.filename ?: ENTRY_NAME_UNKNOWN
28+
val name = file.originalFilename ?: ENTRY_NAME_UNKNOWN
2929
this.scanStream(tika, inputStream, name, authorizedMimeTypes)
3030
}
3131

0 commit comments

Comments
 (0)