Update versions

This commit is contained in:
Alexander Nozik 2023-06-16 11:23:04 +03:00
parent f500d4eb61
commit 62f6436cf6
4 changed files with 12 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
kotlin("jvm") version "1.6.10" kotlin("jvm") version "1.8.22"
application application
} }
@ -13,15 +13,11 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/space/maven") maven("https://maven.pkg.jetbrains.space/public/p/space/maven")
} }
val ktorVersion = "1.6.4"
dependencies { dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion") implementation("org.jetbrains:space-sdk-jvm:159302-beta")
implementation("io.ktor:ktor-client-cio:$ktorVersion") implementation("io.ktor:ktor-client-cio-jvm:2.3.1")
implementation("io.ktor:ktor-client-auth:$ktorVersion") implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.4") implementation("ch.qos.logback:logback-classic:1.4.8")
implementation("org.jetbrains:space-sdk-jvm:98244-beta")
implementation("ch.qos.logback:logback-classic:1.2.10")
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
} }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -14,6 +14,7 @@ import space.jetbrains.api.runtime.types.FolderIdentifier
import space.jetbrains.api.runtime.types.ProjectIdentifier import space.jetbrains.api.runtime.types.ProjectIdentifier
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.Path
suspend fun main(args: Array<String>) { suspend fun main(args: Array<String>) {
val parser = ArgParser("space-document-extractor") val parser = ArgParser("space-document-extractor")
@ -47,7 +48,7 @@ suspend fun main(args: Array<String>) {
parser.parse(args) parser.parse(args)
val target: Path = path?.let { Path.of(path) } ?: Path.of("output/$project") val target: Path = path?.let { Path(it) } ?: Path.of("output/$project")
Files.createDirectories(target) Files.createDirectories(target)

View File

@ -4,6 +4,7 @@ import io.ktor.client.request.header
import io.ktor.client.request.request import io.ktor.client.request.request
import io.ktor.client.request.url import io.ktor.client.request.url
import io.ktor.client.statement.HttpResponse import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.bodyAsChannel
import io.ktor.client.statement.readBytes import io.ktor.client.statement.readBytes
import io.ktor.http.HttpHeaders import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod import io.ktor.http.HttpMethod
@ -33,7 +34,7 @@ internal suspend fun SpaceClient.extractImage(
imageFileName: String, imageFileName: String,
) { ) {
logger.info("Downloading image file $imageFileName to $parent") logger.info("Downloading image file $imageFileName to $parent")
val response = ktorClient.request<HttpResponse> { val response = ktorClient.request {
url("${server.serverUrl}/d/$imageId") url("${server.serverUrl}/d/$imageId")
method = HttpMethod.Get method = HttpMethod.Get
header(HttpHeaders.Authorization, "Bearer ${token().accessToken}") header(HttpHeaders.Authorization, "Bearer ${token().accessToken}")
@ -53,14 +54,14 @@ internal suspend fun SpaceClient.extractFile(
) { ) {
//https://mipt-npm.jetbrains.space/drive/files/3qe9i43qtPq2 //https://mipt-npm.jetbrains.space/drive/files/3qe9i43qtPq2
logger.info("Downloading document file $documentFileName to $parent") logger.info("Downloading document file $documentFileName to $parent")
val response = ktorClient.request<HttpResponse> { val response = ktorClient.request {
url("${server.serverUrl}/drive/files/$documentId") url("${server.serverUrl}/drive/files/$documentId")
method = HttpMethod.Get method = HttpMethod.Get
header(HttpHeaders.Authorization, "Bearer ${token().accessToken}") header(HttpHeaders.Authorization, "Bearer ${token().accessToken}")
} }
val file = parent.resolve(documentFileName) val file = parent.resolve(documentFileName)
file.outputStream().use { file.outputStream().use {
response.content.copyTo(it) response.bodyAsChannel().copyTo(it)
} }
} }