Format files
This commit is contained in:
parent
793218b6bc
commit
8225501488
@ -1,7 +1,7 @@
|
|||||||
package space.kscience.snark.storage
|
package space.kscience.snark.storage
|
||||||
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
public interface Directory : AutoCloseable {
|
public interface Directory : AutoCloseable {
|
||||||
// get file from subtree
|
// get file from subtree
|
||||||
|
@ -3,7 +3,6 @@ package space.kscience.snark.storage.local
|
|||||||
import space.kscience.snark.storage.Directory
|
import space.kscience.snark.storage.Directory
|
||||||
import space.kscience.snark.storage.FileReader
|
import space.kscience.snark.storage.FileReader
|
||||||
import space.kscience.snark.storage.FileWriter
|
import space.kscience.snark.storage.FileWriter
|
||||||
import java.lang.Exception
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.*
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import space.kscience.snark.storage.Directory
|
|||||||
import space.kscience.snark.storage.FileReader
|
import space.kscience.snark.storage.FileReader
|
||||||
import space.kscience.snark.storage.FileWriter
|
import space.kscience.snark.storage.FileWriter
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.div
|
||||||
|
|
||||||
internal class S3Directory(
|
internal class S3Directory(
|
||||||
private val client: S3Client,
|
private val client: S3Client,
|
||||||
|
@ -8,9 +8,9 @@ import aws.smithy.kotlin.runtime.content.toByteArray
|
|||||||
import space.kscience.snark.storage.FileReader
|
import space.kscience.snark.storage.FileReader
|
||||||
import space.kscience.snark.storage.FileWriter
|
import space.kscience.snark.storage.FileWriter
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.*
|
|
||||||
|
|
||||||
internal class S3FileReader(private val client: S3Client, private val bucketName: String, private val path: Path) : FileReader {
|
internal class S3FileReader(private val client: S3Client, private val bucketName: String, private val path: Path) :
|
||||||
|
FileReader {
|
||||||
override suspend fun readAll(): ByteArray {
|
override suspend fun readAll(): ByteArray {
|
||||||
val result = client.getObject(GetObjectRequest {
|
val result = client.getObject(GetObjectRequest {
|
||||||
bucket = bucketName
|
bucket = bucketName
|
||||||
@ -25,7 +25,8 @@ internal class S3FileReader(private val client: S3Client, private val bucketName
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class S3FileWriter(private val client: S3Client, private val bucketName: String, private val path: Path) : FileWriter {
|
internal class S3FileWriter(private val client: S3Client, private val bucketName: String, private val path: Path) :
|
||||||
|
FileWriter {
|
||||||
override suspend fun write(bytes: ByteArray) {
|
override suspend fun write(bytes: ByteArray) {
|
||||||
client.putObject {
|
client.putObject {
|
||||||
bucket = bucketName
|
bucket = bucketName
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package space.kscience.snark.storage.s3
|
package space.kscience.snark.storage.s3
|
||||||
|
|
||||||
import aws.sdk.kotlin.services.s3.*
|
import aws.sdk.kotlin.services.s3.S3Client
|
||||||
|
import aws.sdk.kotlin.services.s3.createBucket
|
||||||
|
import aws.sdk.kotlin.services.s3.headBucket
|
||||||
import space.kscience.snark.storage.Directory
|
import space.kscience.snark.storage.Directory
|
||||||
import space.kscience.snark.storage.FileReader
|
import space.kscience.snark.storage.FileReader
|
||||||
import space.kscience.snark.storage.FileWriter
|
import space.kscience.snark.storage.FileWriter
|
||||||
import java.lang.Exception
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.*
|
import kotlin.io.path.Path
|
||||||
|
|
||||||
public fun s3Storage(client: S3Client): Directory =
|
public fun s3Storage(client: S3Client): Directory =
|
||||||
S3Root(client)
|
S3Root(client)
|
||||||
@ -56,6 +57,7 @@ internal class S3Root(private val client: S3Client) : Directory {
|
|||||||
throw AccessDeniedException(Path(dirname).toFile(), reason = ex.message)
|
throw AccessDeniedException(Path(dirname).toFile(), reason = ex.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Not a good idea")
|
||||||
override val path: Path
|
override val path: Path
|
||||||
get() = Path("")
|
get() = Path("")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user