Skip to content

Commit

Permalink
release 1.14.2: fix FileInfo class variable visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed May 1, 2022
1 parent b897ac7 commit 08694c4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#### < Gradle 7

```groovy
compile 'be.zvz:KotlinInside:1.14.1'
compile 'be.zvz:KotlinInside:1.14.2'
```

#### Gradle 7+

```groovy
implementation 'be.zvz:KotlinInside:1.14.1'
implementation 'be.zvz:KotlinInside:1.14.2'
```

### Maven
Expand All @@ -25,7 +25,7 @@ implementation 'be.zvz:KotlinInside:1.14.1'
<dependency>
<groupId>be.zvz</groupId>
<artifactId>KotlinInside</artifactId>
<version>1.14.1</version>
<version>1.14.2</version>
</dependency>
```

Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ boolean isDev = false

String libName = 'KotlinInside'
String libDevVersion = isDev ? '-SNAPSHOT' : ''
String libVersion = "1.14.1$libDevVersion"
String libVersion = "1.14.2$libDevVersion"
String libDesc = 'Unofficial DCInside API written in Kotlin'

group = 'be.zvz'
Expand All @@ -36,10 +36,13 @@ sourceSets {
}

compileJava {
options.encoding = 'UTF-8'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

javadoc.options.encoding = 'UTF-8'

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.20.1'
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/be/zvz/kotlininside/http/HttpInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ public interface HttpInterface {
final class Option {
public static final class FileInfo {
@NotNull
final InputStream stream;
private final InputStream stream;
@Nullable
final String mimeType;
private final String mimeType;

@NotNull
public InputStream getStream() {
return stream;
}

@Nullable
public String getMimeType() {
return mimeType;
}

public FileInfo(@NotNull InputStream stream) {
this(stream, null);
Expand Down
14 changes: 9 additions & 5 deletions src/main/kotlin/be/zvz/kotlininside/http/DefaultHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class DefaultHttpClient
} else {
request.part(
key,
"image$infix.${fromMimeTypeToExtension(fileInfo.mimeType)}",
"image$infix${fromMimeTypeToExtension(fileInfo.mimeType)}",
fileInfo.mimeType,
fileInfo.stream
)
Expand Down Expand Up @@ -213,19 +213,23 @@ class DefaultHttpClient
val fileName: String
)

private fun fromMimeTypeToExtension(contentType: String): String =
MimeTypes.getDefaultMimeTypes().forName(contentType).extension
private fun fromMimeTypeToExtension(contentType: String?): String =
MimeTypes.getDefaultMimeTypes().forName(contentType ?: DEFAULT_MIME_TYPE).extension
private fun getFileInfoFromStream(inputStream: InputStream, infix: Int): FileInfo {
val contentType = try {
tika.detect(inputStream)
} catch (_: IOException) {
"video/mp4"
DEFAULT_MIME_TYPE
}
return FileInfo(
contentType,
"image$infix.${fromMimeTypeToExtension(contentType)}"
"image$infix${fromMimeTypeToExtension(contentType)}"
)
}

class Proxy internal constructor(var ip: String, var port: Int)

companion object {
const val DEFAULT_MIME_TYPE = "video/mp4"
}
}
2 changes: 0 additions & 2 deletions src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import be.zvz.kotlininside.api.generic.MinorGalleryRanking
import be.zvz.kotlininside.api.type.Article
import be.zvz.kotlininside.api.type.HeadText
import be.zvz.kotlininside.api.type.content.HtmlContent
import be.zvz.kotlininside.api.type.content.ImageContent
import be.zvz.kotlininside.api.type.content.MarkdownContent
import be.zvz.kotlininside.api.type.content.StringContent
import be.zvz.kotlininside.http.DefaultHttpClient
Expand All @@ -19,7 +18,6 @@ import org.junit.jupiter.api.MethodOrderer
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestMethodOrder
import java.net.URL
import java.time.ZoneId
import java.util.*
import java.util.logging.Logger
Expand Down

0 comments on commit 08694c4

Please sign in to comment.