Skip to content

Instantly share code, notes, and snippets.

@mike-seger
Last active May 29, 2025 00:03
Show Gist options
  • Save mike-seger/7cfd44c9c3c61e8a39e03cd2b13152ff to your computer and use it in GitHub Desktop.
Save mike-seger/7cfd44c9c3c61e8a39e03cd2b13152ff to your computer and use it in GitHub Desktop.
correct upload
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.parameters.RequestBody
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import java.util.zip.ZipInputStream
@RestController
@RequestMapping("/api")
class ZipController {
@Operation(
summary = "Upload zip file and list contents",
requestBody = RequestBody(
required = true,
content = [Content(
mediaType = MediaType.MULTIPART_FORM_DATA_VALUE,
schema = Schema(implementation = UploadForm::class)
)]
)
)
@PostMapping("/uploadZip", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun uploadZip(@RequestParam("file") file: MultipartFile): List<String> {
class UploadForm(
@field:Schema(type = "string", format = "binary", description = "Zip file to upload")
val file: MultipartFile? = null
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment