| | package com.keenwrite.processors; |
| | |
| | +import com.keenwrite.io.StreamMediaType; |
| | import com.keenwrite.preferences.Workspace; |
| | |
 |
| | import static java.lang.String.format; |
| | import static java.nio.file.Files.copy; |
| | +import static java.nio.file.Files.move; |
| | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; |
| | import static java.util.regex.Pattern.UNICODE_CHARACTER_CLASS; |
 |
| | |
| | final var contentType = conn.getContentType(); |
| | - final var mediaType = valueFrom( contentType ); |
| | + var mediaType = valueFrom( contentType ); |
| | + |
| | imageFile = mediaType.createTemporaryFile( APP_TITLE_LOWERCASE ); |
| | |
| | - try( final var svgIn = conn.getInputStream() ) { |
| | - copy( svgIn, imageFile, REPLACE_EXISTING ); |
| | + try( final var image = conn.getInputStream() ) { |
| | + copy( image, imageFile, REPLACE_EXISTING ); |
| | } |
| | |
| | conn.disconnect(); |
| | + |
| | + if( mediaType.isUndefined() ) { |
| | + mediaType = StreamMediaType.getMediaType( imageFile ); |
| | + final var file = mediaType.createTemporaryFile( APP_TITLE_LOWERCASE ); |
| | + move( imageFile, file, REPLACE_EXISTING ); |
| | + imageFile = file; |
| | + } |
| | |
| | // Strip comments, superfluous whitespace, DOCTYPE, and XML declarations. |